diff --git a/Mage.Client/src/mage/client/MageFrame.form b/Mage.Client/src/mage/client/MageFrame.form index 372679d87c5..b4d95950829 100644 --- a/Mage.Client/src/mage/client/MageFrame.form +++ b/Mage.Client/src/mage/client/MageFrame.form @@ -1,6 +1,6 @@ -
+ @@ -25,8 +25,8 @@ - - + + @@ -180,6 +180,14 @@ + + + + + + + + diff --git a/Mage.Client/src/mage/client/MageFrame.java b/Mage.Client/src/mage/client/MageFrame.java index de84b19f80c..4d4e998ba95 100644 --- a/Mage.Client/src/mage/client/MageFrame.java +++ b/Mage.Client/src/mage/client/MageFrame.java @@ -41,6 +41,8 @@ import java.io.IOException; import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.Box; +import javax.swing.BoxLayout; import javax.swing.JDesktopPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; @@ -145,6 +147,7 @@ public class MageFrame extends javax.swing.JFrame { btnAbout = new javax.swing.JButton(); jSeparator1 = new javax.swing.JToolBar.Separator(); btnExit = new javax.swing.JButton(); + lblStatus = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setMinimumSize(new java.awt.Dimension(1024, 768)); @@ -239,12 +242,16 @@ public class MageFrame extends javax.swing.JFrame { }); mageToolbar.add(btnExit); + lblStatus.setText("Not connected"); + mageToolbar.add(Box.createHorizontalGlue()); + mageToolbar.add(lblStatus); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, 1106, Short.MAX_VALUE) - .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1106, Short.MAX_VALUE) + .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1066, Short.MAX_VALUE) + .addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, 1066, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -335,32 +342,13 @@ public class MageFrame extends javax.swing.JFrame { private javax.swing.JToolBar.Separator jSeparator2; private javax.swing.JToolBar.Separator jSeparator3; private javax.swing.JToolBar.Separator jSeparator4; + private javax.swing.JLabel lblStatus; private javax.swing.JToolBar mageToolbar; private mage.client.TablesPane tablesPane; // End of variables declaration//GEN-END:variables - private void createDeck() { - Deck deck = new Deck(); - deck.getCards().add(new mage.sets.shardsofalara.BroodmateDragon(null)); - deck.getCards().add(new mage.sets.shardsofalara.BroodmateDragon(null)); - deck.getCards().add(new mage.sets.alarareborn.BloodbraidElf(null)); - deck.getCards().add(new mage.sets.alarareborn.BloodbraidElf(null)); - deck.getCards().add(new mage.sets.shardsofalara.JundPanorama(null)); - deck.getCards().add(new mage.sets.shardsofalara.JundPanorama(null)); - deck.getCards().add(new mage.sets.alarareborn.VengefulRebirth(null)); - deck.getCards().add(new mage.sets.alarareborn.VengefulRebirth(null)); - deck.getCards().add(new mage.sets.shardsofalara.SproutingThrinax(null)); - deck.getCards().add(new mage.sets.shardsofalara.SproutingThrinax(null)); - deck.getCards().add(new mage.sets.shardsofalara.SarkhanVol(null)); - deck.getCards().add(new mage.sets.shardsofalara.SarkhanVol(null)); - deck.getCards().add(new mage.sets.alarareborn.MaelstromPulse(null)); - deck.getCards().add(new mage.sets.alarareborn.MaelstromPulse(null)); - try { - deck.getDeckCardLists().save("test.dck"); - } catch (FileNotFoundException ex) { - logger.log(Level.SEVERE, null, ex); - } catch (IOException ex) { - logger.log(Level.SEVERE, null, ex); - } + public void setStatusText(String status) { + this.lblStatus.setText(status); } + } diff --git a/Mage.Client/src/mage/client/NewPlayerPanel.form b/Mage.Client/src/mage/client/NewPlayerPanel.form index 836e8fbe281..995c12a22f5 100644 --- a/Mage.Client/src/mage/client/NewPlayerPanel.form +++ b/Mage.Client/src/mage/client/NewPlayerPanel.form @@ -17,10 +17,15 @@ - - - - + + + + + + + + + @@ -37,9 +42,9 @@ - - - + + + diff --git a/Mage.Client/src/mage/client/NewPlayerPanel.java b/Mage.Client/src/mage/client/NewPlayerPanel.java index e737e69f029..20f162e5596 100644 --- a/Mage.Client/src/mage/client/NewPlayerPanel.java +++ b/Mage.Client/src/mage/client/NewPlayerPanel.java @@ -35,6 +35,10 @@ package mage.client; import java.io.File; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.prefs.Preferences; import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; @@ -45,20 +49,34 @@ import javax.swing.filechooser.FileFilter; public class NewPlayerPanel extends javax.swing.JPanel { private JFileChooser fcSelectDeck; + private Preferences prefs; /** Creates new form NewPlayerPanel */ public NewPlayerPanel() { initComponents(); + prefs = Preferences.userNodeForPackage(this.getClass()); fcSelectDeck = new JFileChooser(); fcSelectDeck.setAcceptAllFileFilterUsed(false); fcSelectDeck.addChoosableFileFilter(new DeckFilter()); } - public void playerLoadDeck() { + public void setPlayerName(String playerName) { + this.txtPlayerName.setText(playerName); + this.txtPlayerName.setEditable(false); + this.txtPlayerName.setEnabled(false); + } + + protected void playerLoadDeck() { + String lastFolder = prefs.get("lastDeckFolder", ""); + if (!lastFolder.isEmpty()) + fcSelectDeck.setCurrentDirectory(new File(lastFolder)); int ret = fcSelectDeck.showDialog(this, "Select Deck"); if (ret == JFileChooser.APPROVE_OPTION) { File file = fcSelectDeck.getSelectedFile(); this.txtPlayerDeck.setText(file.getPath()); + try { + prefs.put("lastDeckFolder", file.getCanonicalPath()); + } catch (IOException ex) { } } fcSelectDeck.setSelectedFile(null); } @@ -71,13 +89,13 @@ public class NewPlayerPanel extends javax.swing.JPanel { return this.txtPlayerDeck.getText(); } - public void setPlayerName(String playerName) { - this.txtPlayerName.setText(playerName); - } - - public void setDeckFile(String deckFile) { - this.txtPlayerDeck.setText(deckFile); - } +// public void setPlayerName(String playerName) { +// this.txtPlayerName.setText(playerName); +// } +// +// public void setDeckFile(String deckFile) { +// this.txtPlayerDeck.setText(deckFile); +// } /** This method is called from within the constructor to * initialize the form. @@ -110,10 +128,13 @@ public class NewPlayerPanel extends javax.swing.JPanel { layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(lblPlayerDeck) - .addComponent(lblPlayer2Name)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(14, 14, 14) + .addComponent(lblPlayerDeck)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(lblPlayer2Name))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtPlayerName, javax.swing.GroupLayout.DEFAULT_SIZE, 314, Short.MAX_VALUE) @@ -126,9 +147,9 @@ public class NewPlayerPanel extends javax.swing.JPanel { layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(lblPlayer2Name) - .addComponent(txtPlayerName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtPlayerName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lblPlayer2Name)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblPlayerDeck) diff --git a/Mage.Client/src/mage/client/TablesPanel.java b/Mage.Client/src/mage/client/TablesPanel.java index 9b140fd5569..a3de1763bff 100644 --- a/Mage.Client/src/mage/client/TablesPanel.java +++ b/Mage.Client/src/mage/client/TablesPanel.java @@ -116,6 +116,7 @@ public class TablesPanel extends javax.swing.JPanel implements Observer { } + @Override public void update(Observable arg0, Object arg1) { try { tableModel.loadData(roomId); @@ -129,7 +130,7 @@ public class TablesPanel extends javax.swing.JPanel implements Observer { this.roomId = roomId; session = MageFrame.getSession(); - this.btnQuickStart.setVisible(false); + this.btnQuickStart.setVisible(true); if (newTableDialog == null) { newTableDialog = new NewTableDialog(); MageFrame.getDesktop().add(newTableDialog); @@ -258,7 +259,7 @@ public class TablesPanel extends javax.swing.JPanel implements Observer { table = session.createTable( roomId, "Two Player Duel", - Constants.DeckType.CONSTRUCTED_EXTENDED, + "Constructed", playerTypes ); session.joinTable( @@ -378,6 +379,7 @@ class TablesWatchdog extends Observable implements ActionListener { t.start(); } + @Override public void actionPerformed(ActionEvent arg0) { setChanged(); notifyObservers(); diff --git a/Mage.Client/src/mage/client/cards/BigCard.java b/Mage.Client/src/mage/client/cards/BigCard.java index 5e02fdef07e..61568accd98 100644 --- a/Mage.Client/src/mage/client/cards/BigCard.java +++ b/Mage.Client/src/mage/client/cards/BigCard.java @@ -74,9 +74,7 @@ public class BigCard extends javax.swing.JPanel { for (String line: strings) { doc.insertString(doc.getLength(), line + "\n", doc.getStyle("regular")); } - } catch (BadLocationException ble) { - System.err.println("Couldn't insert initial text into text pane."); - } + } catch (BadLocationException ble) { } text.setCaretPosition(0); } diff --git a/Mage.Client/src/mage/client/cards/Card.form b/Mage.Client/src/mage/client/cards/Card.form index 9b3fb336bf3..a0c7c7edbf7 100644 --- a/Mage.Client/src/mage/client/cards/Card.form +++ b/Mage.Client/src/mage/client/cards/Card.form @@ -60,6 +60,9 @@ + + + diff --git a/Mage.Client/src/mage/client/cards/Card.java b/Mage.Client/src/mage/client/cards/Card.java index 7d8c141dc0b..10d30b6b2d6 100644 --- a/Mage.Client/src/mage/client/cards/Card.java +++ b/Mage.Client/src/mage/client/cards/Card.java @@ -34,7 +34,6 @@ package mage.client.cards; -import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; @@ -43,17 +42,17 @@ import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; import java.awt.RenderingHints; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.image.BufferedImage; +import java.util.List; import java.util.UUID; -import javax.swing.BorderFactory; -import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JTextArea; import javax.swing.Popup; import javax.swing.PopupFactory; import javax.swing.text.BadLocationException; @@ -72,7 +71,7 @@ import static mage.client.util.Constants.*; * * @author BetaSteward_at_googlemail.com */ -public class Card extends javax.swing.JPanel implements MouseMotionListener, MouseListener, FocusListener { +public class Card extends javax.swing.JPanel implements MouseMotionListener, MouseListener, FocusListener, ComponentListener { protected static Session session = MageFrame.getSession(); @@ -109,6 +108,7 @@ public class Card extends javax.swing.JPanel implements MouseMotionListener, Mou addFocusListener(this); addMouseMotionListener(this); text.addMouseMotionListener(this); + addComponentListener(this); } public UUID getCardId() { @@ -164,7 +164,7 @@ public class Card extends javax.swing.JPanel implements MouseMotionListener, Mou gSmall.dispose(); } - private String getText(String cardType) { + protected String getText(String cardType) { StringBuilder sb = new StringBuilder(); sb.append(card.getName()).append("\n"); if (card.getManaCost().size() > 0) { @@ -172,7 +172,7 @@ public class Card extends javax.swing.JPanel implements MouseMotionListener, Mou } sb.append(cardType).append("\n"); sb.append(card.getColor().toString()).append("\n"); - for (String rule: card.getRules()) { + for (String rule: getRules()) { sb.append(rule).append("\n"); } if (card.getCardTypes().contains(CardType.CREATURE)) { @@ -184,20 +184,22 @@ public class Card extends javax.swing.JPanel implements MouseMotionListener, Mou return sb.toString(); } - private void drawText() { + protected void drawText() { text.setText(""); StyledDocument doc = text.getStyledDocument(); try { - for (String rule: card.getRules()) + for (String rule: getRules()) doc.insertString(doc.getLength(), rule + "\n", doc.getStyle("small")); - } catch (BadLocationException e) { - System.err.println("Couldn't insert initial text into text pane."); - } + } catch (BadLocationException e) {} text.setCaretPosition(0); } + protected List getRules() { + return card.getRules(); + } + protected String getType(CardView card) { StringBuilder sbType = new StringBuilder(); @@ -243,7 +245,7 @@ public class Card extends javax.swing.JPanel implements MouseMotionListener, Mou text.setBorder(null); text.setEditable(false); - text.setFont(new java.awt.Font("Arial", 0, 9)); + text.setFont(new java.awt.Font("Arial", 0, 9)); // NOI18N text.setFocusable(false); text.setOpaque(false); jScrollPane1.setViewportView(text); @@ -273,7 +275,7 @@ public class Card extends javax.swing.JPanel implements MouseMotionListener, Mou @Override public void mouseMoved(MouseEvent arg0) { - this.bigCard.setCard(card.getId(), image, card.getRules()); + this.bigCard.setCard(card.getId(), image, getRules()); } @Override @@ -328,28 +330,22 @@ public class Card extends javax.swing.JPanel implements MouseMotionListener, Mou // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JTextPane text; + protected javax.swing.JTextPane text; // End of variables declaration//GEN-END:variables -} + @Override + public void componentResized(ComponentEvent e) { } -class TextPopup extends JPanel { + @Override + public void componentMoved(ComponentEvent e) { } - JTextArea txt; + @Override + public void componentShown(ComponentEvent e) { } - public TextPopup() { - super(new BorderLayout()); - this.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); - txt = new JTextArea(1, 20); - txt.setLineWrap(true); - txt.setWrapStyleWord(true); - txt.setEditable(false); - txt.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); - txt.setBackground(Color.lightGray); - this.add(txt); - } - - public void setText(String text) { - txt.setText(text); + @Override + public void componentHidden(ComponentEvent e) { + if (popup != null) + popup.hide(); } -} \ No newline at end of file + +} diff --git a/Mage.Client/src/mage/client/cards/CardGrid.form b/Mage.Client/src/mage/client/cards/CardGrid.form new file mode 100644 index 00000000000..92525c8b11c --- /dev/null +++ b/Mage.Client/src/mage/client/cards/CardGrid.form @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mage.Client/src/mage/client/cards/CardGrid.java b/Mage.Client/src/mage/client/cards/CardGrid.java new file mode 100644 index 00000000000..23958dab594 --- /dev/null +++ b/Mage.Client/src/mage/client/cards/CardGrid.java @@ -0,0 +1,200 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +/* + * CardGrid.java + * + * Created on 30-Mar-2010, 9:25:40 PM + */ + +package mage.client.cards; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Rectangle; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import mage.client.util.Event; +import mage.client.util.Listener; +import mage.view.CardView; +import mage.view.CardsView; +import static mage.client.util.Constants.*; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class CardGrid extends javax.swing.JLayeredPane implements MouseListener, ComponentListener { + + protected CardEventSource cardEventSource = new CardEventSource(); + protected BigCard bigCard; + protected UUID gameId; + protected List cards = new ArrayList(); + + public CardGrid() { + initComponents(); + addComponentListener(this); + setPreferredSize(new Dimension(FRAME_WIDTH, FRAME_HEIGHT)); + } + + public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) { + this.bigCard = bigCard; + this.gameId = gameId; + cards.clear(); + for (CardView card: showCards) { + Card cardImg = new Card(card, bigCard, gameId); + cardImg.update(card); + cardImg.addMouseListener(this); + cards.add(cardImg); + } + drawCards(); + this.setVisible(true); + } + + public void drawCards() { + removeAll(); + int maxWidth = this.getParent().getWidth(); + int numColumns = maxWidth / FRAME_WIDTH; + int curColumn = 0; + int curRow = 0; + if (cards.size() > 0) { + Rectangle rectangle = new Rectangle(FRAME_WIDTH, FRAME_HEIGHT); + for (Card cardImg: cards) { + rectangle.setLocation(curColumn * FRAME_WIDTH, curRow * 20); + cardImg.setBounds(rectangle); + add(cardImg); + moveToFront(cardImg); + curColumn++; + if (curColumn == numColumns) { + curColumn = 0; + curRow++; + } + } + } + resizeArea(); + } + + public void addCardEventListener(Listener listener) { + cardEventSource.addListener(listener); + } + + public void clearCardEventListeners() { + cardEventSource.clearListeners(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 400, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 300, Short.MAX_VALUE) + ); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2 && !e.isConsumed()) { + e.consume(); + cardEventSource.doubleClick(((Card)e.getSource()).getCardId(), "double-click"); + } + } + + @Override + public void mousePressed(MouseEvent e) {} + + @Override + public void mouseReleased(MouseEvent e) {} + + @Override + public void mouseEntered(MouseEvent e) {} + + @Override + public void mouseExited(MouseEvent e) {} + + @Override + public void componentResized(ComponentEvent e) { + resizeArea(); + } + + @Override + public void componentMoved(ComponentEvent e) { + resizeArea(); + } + + @Override + public void componentShown(ComponentEvent e) { + resizeArea(); + } + + @Override + public void componentHidden(ComponentEvent e) { + resizeArea(); + } + + private void resizeArea() { + Dimension area = new Dimension(0, 0); + Dimension size = getPreferredSize(); + + for (Component comp: getComponents()) { + Rectangle r = comp.getBounds(); + if (r.x + r.width > area.width) { + area.width = r.x + r.width; + } + if (r.y + r.height > area.height) { + area.height = r.y + r.height; + } + } + if (size.height != area.height || size.width != area.width) { + setPreferredSize(area); + revalidate(); + repaint(); + } + + } +} diff --git a/Mage.Client/src/mage/client/cards/CardsList.java b/Mage.Client/src/mage/client/cards/CardsList.java index 8a2f98264a3..afd92c088be 100644 --- a/Mage.Client/src/mage/client/cards/CardsList.java +++ b/Mage.Client/src/mage/client/cards/CardsList.java @@ -38,8 +38,6 @@ import java.awt.Dimension; import java.awt.Rectangle; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import java.util.Collection; -import java.util.List; import java.util.UUID; import mage.client.util.Event; import mage.client.util.Listener; diff --git a/Mage.Client/src/mage/client/cards/Permanent.java b/Mage.Client/src/mage/client/cards/Permanent.java index 791848b3c7d..a2e1adf7ee4 100644 --- a/Mage.Client/src/mage/client/cards/Permanent.java +++ b/Mage.Client/src/mage/client/cards/Permanent.java @@ -45,7 +45,11 @@ import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import javax.swing.PopupFactory; +import javax.swing.text.BadLocationException; +import javax.swing.text.StyledDocument; import mage.client.util.ImageHelper; +import mage.view.CounterView; import mage.view.PermanentView; import static mage.client.util.Constants.*; @@ -85,6 +89,19 @@ public class Permanent extends Card { this.linked = linked; } + @Override + protected List getRules() { + if (permanent.getCounters() != null) { + List rules = new ArrayList(permanent.getRules()); + for (CounterView counter: permanent.getCounters()) + rules.add(counter.getCount() + " x " + counter.getName()); + return rules; + } + else { + return permanent.getRules(); + } + } + @Override public void mousePressed(MouseEvent e) { p = e.getPoint(); @@ -111,6 +128,12 @@ public class Permanent extends Card { } } + @Override + public void mouseClicked(MouseEvent arg0) { + + super.mouseClicked(arg0); + } + @Override public void paintComponent(Graphics graphics) { Graphics2D g2 = (Graphics2D) graphics; @@ -179,6 +202,21 @@ public class Permanent extends Card { return this.getBounds().intersects(r1); } + @Override + public void mouseEntered(MouseEvent arg0) { + if (popup != null) + popup.hide(); + PopupFactory factory = PopupFactory.getSharedInstance(); + int x = (int) this.getLocationOnScreen().getX() + (permanent.isTapped()?FRAME_HEIGHT:FRAME_WIDTH); + int y = (int) this.getLocationOnScreen().getY() + 40; + popup = factory.getPopup(this, popupText, x, y); + popup.show(); + //hack to get popup to resize to fit text + popup.hide(); + popup = factory.getPopup(this, popupText, x, y); + popup.show(); + } + /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is diff --git a/Mage.Client/src/mage/client/cards/TextPopup.form b/Mage.Client/src/mage/client/cards/TextPopup.form new file mode 100644 index 00000000000..bb8d8df8ace --- /dev/null +++ b/Mage.Client/src/mage/client/cards/TextPopup.form @@ -0,0 +1,49 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mage.Client/src/mage/client/cards/TextPopup.java b/Mage.Client/src/mage/client/cards/TextPopup.java new file mode 100644 index 00000000000..7bec0cc5fa6 --- /dev/null +++ b/Mage.Client/src/mage/client/cards/TextPopup.java @@ -0,0 +1,81 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +/* + * TextPopup.java + * + * Created on Apr 6, 2010, 9:36:13 AM + */ + +package mage.client.cards; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class TextPopup extends javax.swing.JPanel { + + /** Creates new form TextPopup */ + public TextPopup() { + initComponents(); + } + + public void setText(String text) { + popupText.setText(text); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + popupText = new javax.swing.JTextArea(); + + setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + setLayout(new java.awt.BorderLayout()); + + popupText.setBackground(new java.awt.Color(204, 204, 204)); + popupText.setColumns(20); + popupText.setEditable(false); + popupText.setLineWrap(true); + popupText.setRows(1); + popupText.setWrapStyleWord(true); + popupText.setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 2, 2, 2)); + add(popupText, java.awt.BorderLayout.PAGE_START); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextArea popupText; + // End of variables declaration//GEN-END:variables + +} diff --git a/Mage.Client/src/mage/client/deckeditor/CardSelector.form b/Mage.Client/src/mage/client/deckeditor/CardSelector.form index bdd19d1dd1f..8a25cb91e77 100644 --- a/Mage.Client/src/mage/client/deckeditor/CardSelector.form +++ b/Mage.Client/src/mage/client/deckeditor/CardSelector.form @@ -16,23 +16,27 @@ - - + + + - + - + + + - + + @@ -101,7 +105,7 @@ - + @@ -110,9 +114,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - diff --git a/Mage.Client/src/mage/client/deckeditor/CardSelector.java b/Mage.Client/src/mage/client/deckeditor/CardSelector.java index dff0aa23954..1c34ec8a762 100644 --- a/Mage.Client/src/mage/client/deckeditor/CardSelector.java +++ b/Mage.Client/src/mage/client/deckeditor/CardSelector.java @@ -35,28 +35,26 @@ package mage.client.deckeditor; import java.awt.Cursor; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import javax.swing.DefaultComboBoxModel; +import mage.Constants.CardType; import mage.Constants.Zone; import mage.cards.Cards; import mage.cards.CardsImpl; +import mage.cards.ExpansionSet; import mage.client.cards.BigCard; -import mage.client.cards.CardsList; +import mage.client.cards.CardGrid; import mage.filter.Filter.ComparisonScope; import mage.filter.FilterCard; -import mage.sets.AlaraReborn; -import mage.sets.Conflux; -import mage.sets.Magic2010; -import mage.sets.Planechase; -import mage.sets.ShardsOfAlara; -import mage.sets.Tenth; -import mage.sets.Worldwake; -import mage.sets.Zendikar; +import mage.sets.Sets; import mage.view.CardsView; /** * * @author BetaSteward_at_googlemail.com */ -public class CardSelector extends javax.swing.JPanel { +public class CardSelector extends javax.swing.JPanel implements ComponentListener { private Cards cards = new CardsImpl(Zone.OUTSIDE); private FilterCard filter = new FilterCard(); @@ -65,19 +63,18 @@ public class CardSelector extends javax.swing.JPanel { /** Creates new form CardSelector */ public CardSelector() { initComponents(); + this.addComponentListener(this); } public void loadCards(BigCard bigCard) { this.bigCard = bigCard; this.cards.clear(); - cards.addAll(AlaraReborn.getInstance().createCards()); - cards.addAll(Conflux.getInstance().createCards()); - cards.addAll(Magic2010.getInstance().createCards()); - cards.addAll(Planechase.getInstance().createCards()); - cards.addAll(ShardsOfAlara.getInstance().createCards()); - cards.addAll(Tenth.getInstance().createCards()); - cards.addAll(Worldwake.getInstance().createCards()); - cards.addAll(Zendikar.getInstance().createCards()); + cbExpansionSet.setModel(new DefaultComboBoxModel(Sets.getInstance().toArray())); + cbExpansionSet.insertItemAt("All sets", 0); + cbExpansionSet.setSelectedIndex(0); + for (ExpansionSet set: Sets.getInstance()) { + cards.addAll(set.createCards()); + } filter.setUseColor(true); filter.getColor().setBlack(true); filter.getColor().setBlue(true); @@ -88,21 +85,29 @@ public class CardSelector extends javax.swing.JPanel { filter.setUseColorless(true); filter.setNotColor(false); filter.setScopeColor(ComparisonScope.Any); + filter.getCardType().add(CardType.LAND); + filter.getCardType().add(CardType.ARTIFACT); + filter.getCardType().add(CardType.CREATURE); + filter.getCardType().add(CardType.ENCHANTMENT); + filter.getCardType().add(CardType.INSTANT); + filter.getCardType().add(CardType.PLANESWALKER); + filter.getCardType().add(CardType.SORCERY); + filter.setScopeCardType(ComparisonScope.Any); filterCards(); } private void filterCards() { try { setCursor(new Cursor(Cursor.WAIT_CURSOR)); - this.cardsList1.loadCards(new CardsView(cards.getCards(filter)), bigCard, null); + this.cardGrid.loadCards(new CardsView(cards.getCards(filter)), bigCard, null); } finally { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } - public CardsList getCardsList() { - return this.cardsList1; + public CardGrid getCardsList() { + return this.cardGrid; } public Cards getCards() { @@ -118,16 +123,27 @@ public class CardSelector extends javax.swing.JPanel { // //GEN-BEGIN:initComponents private void initComponents() { - jToolBar1 = new javax.swing.JToolBar(); + tbColor = new javax.swing.JToolBar(); rdoRed = new javax.swing.JRadioButton(); rdoGreen = new javax.swing.JRadioButton(); rdoBlue = new javax.swing.JRadioButton(); rdoBlack = new javax.swing.JRadioButton(); rdoWhite = new javax.swing.JRadioButton(); rdoColorless = new javax.swing.JRadioButton(); - cardsList1 = new mage.client.cards.CardsList(); + cbExpansionSet = new javax.swing.JComboBox(); + jScrollPane1 = new javax.swing.JScrollPane(); + cardGrid = new mage.client.cards.CardGrid(); + tbTypes = new javax.swing.JToolBar(); + rdoLand = new javax.swing.JRadioButton(); + rdoCreatures = new javax.swing.JRadioButton(); + rdoArtifacts = new javax.swing.JRadioButton(); + rdoEnchantments = new javax.swing.JRadioButton(); + rdoInstants = new javax.swing.JRadioButton(); + rdoSorceries = new javax.swing.JRadioButton(); + rdoPlaneswalkers = new javax.swing.JRadioButton(); - jToolBar1.setRollover(true); + tbColor.setFloatable(false); + tbColor.setRollover(true); rdoRed.setSelected(true); rdoRed.setText("Red "); @@ -139,7 +155,7 @@ public class CardSelector extends javax.swing.JPanel { rdoRedActionPerformed(evt); } }); - jToolBar1.add(rdoRed); + tbColor.add(rdoRed); rdoGreen.setSelected(true); rdoGreen.setText("Green "); @@ -151,7 +167,7 @@ public class CardSelector extends javax.swing.JPanel { rdoGreenActionPerformed(evt); } }); - jToolBar1.add(rdoGreen); + tbColor.add(rdoGreen); rdoBlue.setSelected(true); rdoBlue.setText("Blue "); @@ -163,7 +179,7 @@ public class CardSelector extends javax.swing.JPanel { rdoBlueActionPerformed(evt); } }); - jToolBar1.add(rdoBlue); + tbColor.add(rdoBlue); rdoBlack.setSelected(true); rdoBlack.setText("Black "); @@ -175,7 +191,7 @@ public class CardSelector extends javax.swing.JPanel { rdoBlackActionPerformed(evt); } }); - jToolBar1.add(rdoBlack); + tbColor.add(rdoBlack); rdoWhite.setSelected(true); rdoWhite.setText("White "); @@ -187,10 +203,10 @@ public class CardSelector extends javax.swing.JPanel { rdoWhiteActionPerformed(evt); } }); - jToolBar1.add(rdoWhite); + tbColor.add(rdoWhite); rdoColorless.setSelected(true); - rdoColorless.setText("Colorless"); + rdoColorless.setText("Colorless "); rdoColorless.setFocusable(false); rdoColorless.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); rdoColorless.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); @@ -199,21 +215,121 @@ public class CardSelector extends javax.swing.JPanel { rdoColorlessActionPerformed(evt); } }); - jToolBar1.add(rdoColorless); + tbColor.add(rdoColorless); + + cbExpansionSet.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + cbExpansionSet.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cbExpansionSetActionPerformed(evt); + } + }); + tbColor.add(cbExpansionSet); + + jScrollPane1.setViewportView(cardGrid); + + tbTypes.setFloatable(false); + tbTypes.setRollover(true); + + rdoLand.setSelected(true); + rdoLand.setFocusable(false); + rdoLand.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); + rdoLand.setLabel("Land "); + rdoLand.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + rdoLand.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + rdoLandActionPerformed(evt); + } + }); + tbTypes.add(rdoLand); + + rdoCreatures.setSelected(true); + rdoCreatures.setFocusable(false); + rdoCreatures.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); + rdoCreatures.setLabel("Creatures "); + rdoCreatures.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + rdoCreatures.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + rdoCreaturesActionPerformed(evt); + } + }); + tbTypes.add(rdoCreatures); + + rdoArtifacts.setSelected(true); + rdoArtifacts.setText("Artifacts "); + rdoArtifacts.setFocusable(false); + rdoArtifacts.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); + rdoArtifacts.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + rdoArtifacts.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + rdoArtifactsActionPerformed(evt); + } + }); + tbTypes.add(rdoArtifacts); + + rdoEnchantments.setSelected(true); + rdoEnchantments.setText("Enchantments "); + rdoEnchantments.setFocusable(false); + rdoEnchantments.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); + rdoEnchantments.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + rdoEnchantments.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + rdoEnchantmentsActionPerformed(evt); + } + }); + tbTypes.add(rdoEnchantments); + + rdoInstants.setSelected(true); + rdoInstants.setText("Instants "); + rdoInstants.setFocusable(false); + rdoInstants.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); + rdoInstants.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + rdoInstants.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + rdoInstantsActionPerformed(evt); + } + }); + tbTypes.add(rdoInstants); + + rdoSorceries.setSelected(true); + rdoSorceries.setText("Sorceries "); + rdoSorceries.setFocusable(false); + rdoSorceries.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); + rdoSorceries.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + rdoSorceries.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + rdoSorceriesActionPerformed(evt); + } + }); + tbTypes.add(rdoSorceries); + + rdoPlaneswalkers.setSelected(true); + rdoPlaneswalkers.setText("Planeswalkers "); + rdoPlaneswalkers.setFocusable(false); + rdoPlaneswalkers.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); + rdoPlaneswalkers.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + rdoPlaneswalkers.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + rdoPlaneswalkersActionPerformed(evt); + } + }); + tbTypes.add(rdoPlaneswalkers); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 825, Short.MAX_VALUE) - .addComponent(cardsList1, javax.swing.GroupLayout.DEFAULT_SIZE, 825, Short.MAX_VALUE) + .addComponent(tbColor, javax.swing.GroupLayout.DEFAULT_SIZE, 825, Short.MAX_VALUE) + .addComponent(tbTypes, javax.swing.GroupLayout.DEFAULT_SIZE, 825, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 825, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(tbColor, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0) - .addComponent(cardsList1, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)) + .addComponent(tbTypes, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 316, Short.MAX_VALUE)) ); }// //GEN-END:initComponents @@ -247,16 +363,110 @@ public class CardSelector extends javax.swing.JPanel { filterCards(); }//GEN-LAST:event_rdoColorlessActionPerformed + private void rdoLandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoLandActionPerformed + if (this.rdoLand.isSelected()) + filter.getCardType().add(CardType.LAND); + else + filter.getCardType().remove(CardType.LAND); + filterCards(); + }//GEN-LAST:event_rdoLandActionPerformed + + private void rdoCreaturesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoCreaturesActionPerformed + if (this.rdoCreatures.isSelected()) + filter.getCardType().add(CardType.CREATURE); + else + filter.getCardType().remove(CardType.CREATURE); + filterCards(); + }//GEN-LAST:event_rdoCreaturesActionPerformed + + private void rdoArtifactsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoArtifactsActionPerformed + if (this.rdoArtifacts.isSelected()) + filter.getCardType().add(CardType.ARTIFACT); + else + filter.getCardType().remove(CardType.ARTIFACT); + filterCards(); + }//GEN-LAST:event_rdoArtifactsActionPerformed + + private void rdoEnchantmentsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoEnchantmentsActionPerformed + if (this.rdoEnchantments.isSelected()) + filter.getCardType().add(CardType.ENCHANTMENT); + else + filter.getCardType().remove(CardType.ENCHANTMENT); + filterCards(); + }//GEN-LAST:event_rdoEnchantmentsActionPerformed + + private void rdoInstantsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoInstantsActionPerformed + if (this.rdoInstants.isSelected()) + filter.getCardType().add(CardType.INSTANT); + else + filter.getCardType().remove(CardType.INSTANT); + filterCards(); + }//GEN-LAST:event_rdoInstantsActionPerformed + + private void rdoSorceriesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoSorceriesActionPerformed + if (this.rdoSorceries.isSelected()) + filter.getCardType().add(CardType.SORCERY); + else + filter.getCardType().remove(CardType.SORCERY); + filterCards(); + }//GEN-LAST:event_rdoSorceriesActionPerformed + + private void rdoPlaneswalkersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoPlaneswalkersActionPerformed + if (this.rdoPlaneswalkers.isSelected()) + filter.getCardType().add(CardType.PLANESWALKER); + else + filter.getCardType().remove(CardType.PLANESWALKER); + filterCards(); + }//GEN-LAST:event_rdoPlaneswalkersActionPerformed + + private void cbExpansionSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbExpansionSetActionPerformed + filter.getExpansionSetId().clear(); + if (cbExpansionSet.getSelectedItem() instanceof ExpansionSet) { + filter.getExpansionSetId().add(((ExpansionSet)this.cbExpansionSet.getSelectedItem()).getId()); + } + filterCards(); + }//GEN-LAST:event_cbExpansionSetActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables - private mage.client.cards.CardsList cardsList1; - private javax.swing.JToolBar jToolBar1; + private mage.client.cards.CardGrid cardGrid; + private javax.swing.JComboBox cbExpansionSet; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JRadioButton rdoArtifacts; private javax.swing.JRadioButton rdoBlack; private javax.swing.JRadioButton rdoBlue; private javax.swing.JRadioButton rdoColorless; + private javax.swing.JRadioButton rdoCreatures; + private javax.swing.JRadioButton rdoEnchantments; private javax.swing.JRadioButton rdoGreen; + private javax.swing.JRadioButton rdoInstants; + private javax.swing.JRadioButton rdoLand; + private javax.swing.JRadioButton rdoPlaneswalkers; private javax.swing.JRadioButton rdoRed; + private javax.swing.JRadioButton rdoSorceries; private javax.swing.JRadioButton rdoWhite; + private javax.swing.JToolBar tbColor; + private javax.swing.JToolBar tbTypes; // End of variables declaration//GEN-END:variables + @Override + public void componentResized(ComponentEvent e) { + this.cardGrid.drawCards(); + } + + @Override + public void componentMoved(ComponentEvent e) { + this.cardGrid.drawCards(); + } + + @Override + public void componentShown(ComponentEvent e) { + this.cardGrid.drawCards(); + } + + @Override + public void componentHidden(ComponentEvent e) { + this.cardGrid.drawCards(); + } + } diff --git a/Mage.Client/src/mage/client/deckeditor/DeckEditorPanel.java b/Mage.Client/src/mage/client/deckeditor/DeckEditorPanel.java index 8e99072e21a..d630b5c08ee 100644 --- a/Mage.Client/src/mage/client/deckeditor/DeckEditorPanel.java +++ b/Mage.Client/src/mage/client/deckeditor/DeckEditorPanel.java @@ -36,10 +36,12 @@ package mage.client.deckeditor; import java.awt.Cursor; import java.io.File; +import java.io.IOException; import java.lang.reflect.Constructor; import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.prefs.Preferences; import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; import mage.cards.Card; @@ -57,10 +59,12 @@ public class DeckEditorPanel extends javax.swing.JPanel { private JFileChooser fcSelectDeck; private Deck deck = new Deck();; + private Preferences prefs; /** Creates new form DeckEditorPanel */ public DeckEditorPanel() { initComponents(); + prefs = Preferences.userNodeForPackage(this.getClass()); fcSelectDeck = new JFileChooser(); fcSelectDeck.setAcceptAllFileFilterUsed(false); fcSelectDeck.addChoosableFileFilter(new DeckFilter()); @@ -236,6 +240,9 @@ public class DeckEditorPanel extends javax.swing.JPanel { }// //GEN-END:initComponents private void btnLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadActionPerformed + String lastFolder = prefs.get("lastDeckFolder", ""); + if (!lastFolder.isEmpty()) + fcSelectDeck.setCurrentDirectory(new File(lastFolder)); int ret = fcSelectDeck.showOpenDialog(this); if (ret == JFileChooser.APPROVE_OPTION) { File file = fcSelectDeck.getSelectedFile(); @@ -249,11 +256,17 @@ public class DeckEditorPanel extends javax.swing.JPanel { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } refreshDeck(); + try { + prefs.put("lastDeckFolder", file.getCanonicalPath()); + } catch (IOException ex) { } } fcSelectDeck.setSelectedFile(null); }//GEN-LAST:event_btnLoadActionPerformed private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed + String lastFolder = prefs.get("lastDeckFolder", ""); + if (!lastFolder.isEmpty()) + fcSelectDeck.setCurrentDirectory(new File(lastFolder)); deck.setName(this.txtDeckName.getText()); int ret = fcSelectDeck.showSaveDialog(this); if (ret == JFileChooser.APPROVE_OPTION) { @@ -267,6 +280,9 @@ public class DeckEditorPanel extends javax.swing.JPanel { finally { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } + try { + prefs.put("lastDeckFolder", file.getCanonicalPath()); + } catch (IOException ex) { } } }//GEN-LAST:event_btnSaveActionPerformed diff --git a/Mage.Client/src/mage/client/dialog/CombatDialog.java b/Mage.Client/src/mage/client/dialog/CombatDialog.java index e56f8bf82c1..a554333a8fa 100644 --- a/Mage.Client/src/mage/client/dialog/CombatDialog.java +++ b/Mage.Client/src/mage/client/dialog/CombatDialog.java @@ -34,10 +34,8 @@ package mage.client.dialog; -import java.awt.Dimension; import java.util.List; import java.util.UUID; -import javax.swing.JLayeredPane; import mage.client.cards.BigCard; import mage.client.game.CombatGroup; import mage.view.CombatGroupView; @@ -69,11 +67,9 @@ public class CombatDialog extends MageDialog { combatGroup.init(gameId, bigCard); combatGroup.update(group); combatGroup.setVisible(true); -// combatGroup.setPreferredSize(new Dimension(140, 440)); combatArea.add(combatGroup); combatGroup.revalidate(); } -// combatArea.setPreferredSize(new Dimension(140, 440)); pack(); this.revalidate(); this.repaint(); diff --git a/Mage.Client/src/mage/client/dialog/ConnectDialog.java b/Mage.Client/src/mage/client/dialog/ConnectDialog.java index ffdb7fc8a1d..cdc9dea3685 100644 --- a/Mage.Client/src/mage/client/dialog/ConnectDialog.java +++ b/Mage.Client/src/mage/client/dialog/ConnectDialog.java @@ -193,6 +193,7 @@ public class ConnectDialog extends MageDialog { } setCursor(new Cursor(Cursor.WAIT_CURSOR)); session.connect(txtUserName.getText(), txtServer.getText(), Integer.valueOf(txtPort.getText())); + prefs.put("serverAddress", txtServer.getText()); prefs.put("serverPort", txtPort.getText()); prefs.put("userName", txtUserName.getText()); diff --git a/Mage.Client/src/mage/client/dialog/MageDialog.java b/Mage.Client/src/mage/client/dialog/MageDialog.java index 4f76ba5ed6f..ea718e3c2c2 100644 --- a/Mage.Client/src/mage/client/dialog/MageDialog.java +++ b/Mage.Client/src/mage/client/dialog/MageDialog.java @@ -82,6 +82,7 @@ public class MageDialog extends javax.swing.JInternalFrame { } else { try { SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { stopModal(); } diff --git a/Mage.Client/src/mage/client/dialog/NewTableDialog.form b/Mage.Client/src/mage/client/dialog/NewTableDialog.form index 5af2848a2f9..5ed6063aae3 100644 --- a/Mage.Client/src/mage/client/dialog/NewTableDialog.form +++ b/Mage.Client/src/mage/client/dialog/NewTableDialog.form @@ -33,12 +33,6 @@ - - - - - - @@ -53,6 +47,12 @@ + + + + + + @@ -80,12 +80,12 @@ - + - + - + @@ -104,11 +104,6 @@ - - - - - diff --git a/Mage.Client/src/mage/client/dialog/NewTableDialog.java b/Mage.Client/src/mage/client/dialog/NewTableDialog.java index 63e7280eb65..c0fe272497f 100644 --- a/Mage.Client/src/mage/client/dialog/NewTableDialog.java +++ b/Mage.Client/src/mage/client/dialog/NewTableDialog.java @@ -42,7 +42,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.DefaultComboBoxModel; import javax.swing.JOptionPane; -import mage.Constants; import mage.cards.decks.DeckCardLists; import mage.client.remote.Session; import mage.util.Logging; @@ -99,8 +98,6 @@ public class NewTableDialog extends MageDialog { lbDeckType.setText("Deck Type:"); - cbDeckType.setModel(new DefaultComboBoxModel(Constants.DeckType.values())); - lbPlayer2Type.setText("Player 2 Type:"); cbPlayer2Type.addActionListener(new java.awt.event.ActionListener() { @@ -138,11 +135,6 @@ public class NewTableDialog extends MageDialog { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(cbDeckType, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap() - .addComponent(btnOK) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(btnCancel)) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(lbPlayer2Type) @@ -153,7 +145,12 @@ public class NewTableDialog extends MageDialog { .addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addContainerGap() - .addComponent(player2Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE))) + .addComponent(player2Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(360, Short.MAX_VALUE) + .addComponent(btnOK) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btnCancel))) .addContainerGap()) ); layout.setVerticalGroup( @@ -175,11 +172,11 @@ public class NewTableDialog extends MageDialog { .addComponent(cbPlayer2Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(player2Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(13, 13, 13) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(btnOK) - .addComponent(btnCancel)) - .addContainerGap(39, Short.MAX_VALUE)) + .addComponent(btnCancel) + .addComponent(btnOK)) + .addContainerGap()) ); pack(); @@ -198,6 +195,10 @@ public class NewTableDialog extends MageDialog { else { this.player2Panel.setVisible(false); } + this.pack(); + this.revalidate(); + this.repaint(); + }//GEN-LAST:event_cbPlayer2TypeActionPerformed private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed @@ -208,30 +209,34 @@ public class NewTableDialog extends MageDialog { table = session.createTable( roomId, (String)this.cbGameType.getSelectedItem(), - (Constants.DeckType)this.cbDeckType.getSelectedItem(), + (String)this.cbDeckType.getSelectedItem(), playerTypes ); - session.joinTable( + if (session.joinTable( roomId, table.getTableId(), 0, this.player1Panel.getPlayerName(), DeckCardLists.load(this.player1Panel.getDeckFile()) - ); - if (!this.cbPlayer2Type.getSelectedItem().equals("Human")) { - session.joinTable( - roomId, - table.getTableId(), - 1, - this.player2Panel.getPlayerName(), - DeckCardLists.load(this.player2Panel.getDeckFile()) - ); + )) { + if (!this.cbPlayer2Type.getSelectedItem().equals("Human")) { + if (session.joinTable( + roomId, + table.getTableId(), + 1, + this.player2Panel.getPlayerName(), + DeckCardLists.load(this.player2Panel.getDeckFile()) + )) { + this.setVisible(false); + return; + } + } } } catch (Exception ex) { handleError(ex); } - - this.setVisible(false); + session.removeTable(roomId, table.getTableId()); + table = null; }//GEN-LAST:event_btnOKActionPerformed private void handleError(Exception ex) { @@ -241,10 +246,15 @@ public class NewTableDialog extends MageDialog { public void showDialog(UUID roomId) { session = MageFrame.getSession(); + this.player1Panel.setPlayerName(session.getUserName()); cbGameType.setModel(new DefaultComboBoxModel(session.getGameTypes())); + cbDeckType.setModel(new DefaultComboBoxModel(session.getDeckTypes())); cbPlayer2Type.setModel(new DefaultComboBoxModel(session.getPlayerTypes())); this.roomId = roomId; this.setModal(true); + this.pack(); + this.revalidate(); + this.repaint(); this.setVisible(true); } diff --git a/Mage.Client/src/mage/client/dialog/ShowCardsDialog.java b/Mage.Client/src/mage/client/dialog/ShowCardsDialog.java index e9009788f5f..0ec4f181015 100644 --- a/Mage.Client/src/mage/client/dialog/ShowCardsDialog.java +++ b/Mage.Client/src/mage/client/dialog/ShowCardsDialog.java @@ -36,11 +36,8 @@ package mage.client.dialog; import java.awt.Dimension; import java.awt.Rectangle; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import java.util.Collection; import java.util.UUID; import javax.swing.JLayeredPane; import mage.client.MageFrame; @@ -65,6 +62,34 @@ public class ShowCardsDialog extends MageDialog implements MouseListener { public void loadCards(String name, CardsView showCards, BigCard bigCard, UUID gameId) { this.title = name; cardArea.removeAll(); + if (showCards != null && showCards.size() < 10) + loadCardsFew(showCards, bigCard, gameId); + else + loadCardsMany(showCards, bigCard, gameId); + cardArea.revalidate(); + if (getParent() != MageFrame.getDesktop() || this.isClosed) + MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER); + pack(); + this.revalidate(); + this.repaint(); + this.setVisible(true); + } + + private void loadCardsFew(CardsView showCards, BigCard bigCard, UUID gameId) { + Rectangle rectangle = new Rectangle(FRAME_WIDTH, FRAME_HEIGHT); + for (CardView card: showCards) { + Card cardImg = new Card(card, bigCard, gameId); + cardImg.setBounds(rectangle); + cardArea.add(cardImg); + cardArea.moveToFront(cardImg); + cardImg.update(card); + cardImg.addMouseListener(this); + rectangle.translate(FRAME_WIDTH, 0); + } + cardArea.setPreferredSize(new Dimension(FRAME_WIDTH * showCards.size(), FRAME_HEIGHT)); + } + + private void loadCardsMany(CardsView showCards, BigCard bigCard, UUID gameId) { int columns = 1; if (showCards != null && showCards.size() > 0) { Rectangle rectangle = new Rectangle(FRAME_WIDTH, FRAME_HEIGHT); @@ -87,13 +112,6 @@ public class ShowCardsDialog extends MageDialog implements MouseListener { } } cardArea.setPreferredSize(new Dimension(FRAME_WIDTH * columns, FRAME_HEIGHT + 400)); - cardArea.revalidate(); - if (getParent() != MageFrame.getDesktop() || this.isClosed) - MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER); - pack(); - this.revalidate(); - this.repaint(); - this.setVisible(true); } /** This method is called from within the constructor to @@ -124,6 +142,7 @@ public class ShowCardsDialog extends MageDialog implements MouseListener { private javax.swing.JScrollPane jScrollPane1; // End of variables declaration//GEN-END:variables + @Override public void mouseClicked(MouseEvent e) { this.setVisible(false); } diff --git a/Mage.Client/src/mage/client/game/BattlefieldPanel.form b/Mage.Client/src/mage/client/game/BattlefieldPanel.form index 9c3d3fbde2d..40a01094ae4 100644 --- a/Mage.Client/src/mage/client/game/BattlefieldPanel.form +++ b/Mage.Client/src/mage/client/game/BattlefieldPanel.form @@ -1,6 +1,6 @@ -
+ @@ -14,7 +14,5 @@ - - - + diff --git a/Mage.Client/src/mage/client/game/BattlefieldPanel.java b/Mage.Client/src/mage/client/game/BattlefieldPanel.java index 3b309299524..6d5e898d93a 100644 --- a/Mage.Client/src/mage/client/game/BattlefieldPanel.java +++ b/Mage.Client/src/mage/client/game/BattlefieldPanel.java @@ -53,7 +53,7 @@ import static mage.client.util.Constants.*; * * @author BetaSteward_at_googlemail.com */ -public class BattlefieldPanel extends javax.swing.JPanel implements ComponentListener { +public class BattlefieldPanel extends javax.swing.JLayeredPane implements ComponentListener { private Map permanents = new HashMap(); private UUID gameId; @@ -98,11 +98,13 @@ public class BattlefieldPanel extends javax.swing.JPanel implements ComponentLis perm.setBounds(findEmptySpace(new Dimension(FRAME_WIDTH, FRAME_HEIGHT))); permanents.put(permanent.getId(), perm); this.add(perm); + moveToFront(perm); perm.update(permanent); } private void groupAttachments(PermanentView permanent) { Permanent perm = permanents.get(permanent.getId()); + int position = getPosition(perm); perm.getLinks().clear(); Rectangle r = perm.getBounds(); for (UUID attachmentId: permanent.getAttachments()) { @@ -110,6 +112,7 @@ public class BattlefieldPanel extends javax.swing.JPanel implements ComponentLis perm.getLinks().add(link); r.translate(20, 20); link.setBounds(r); + setPosition(link, ++position); } } @@ -163,18 +166,22 @@ public class BattlefieldPanel extends javax.swing.JPanel implements ComponentLis setLayout(null); }// //GEN-END:initComponents + @Override public void componentResized(ComponentEvent e) { resizeBattlefield(); } + @Override public void componentMoved(ComponentEvent e) { resizeBattlefield(); } + @Override public void componentShown(ComponentEvent e) { resizeBattlefield(); } + @Override public void componentHidden(ComponentEvent e) { resizeBattlefield(); } diff --git a/Mage.Client/src/mage/client/game/GamePanel.java b/Mage.Client/src/mage/client/game/GamePanel.java index 9b93b97248a..411ccec335e 100644 --- a/Mage.Client/src/mage/client/game/GamePanel.java +++ b/Mage.Client/src/mage/client/game/GamePanel.java @@ -78,7 +78,7 @@ public class GamePanel extends javax.swing.JPanel { initComponents(); } - public void showGame(UUID gameId, UUID playerId) { + public synchronized void showGame(UUID gameId, UUID playerId) { this.gameId = gameId; session = MageFrame.getSession(); session.setGame(this); @@ -94,7 +94,7 @@ public class GamePanel extends javax.swing.JPanel { hideGame(); } - public void watchGame(UUID gameId) { + public synchronized void watchGame(UUID gameId) { this.gameId = gameId; session = MageFrame.getSession(); session.setGame(this); @@ -109,7 +109,7 @@ public class GamePanel extends javax.swing.JPanel { hideGame(); } - public void replayGame(UUID gameId) { + public synchronized void replayGame(UUID gameId) { this.gameId = gameId; session = MageFrame.getSession(); session.setGame(this); @@ -126,11 +126,11 @@ public class GamePanel extends javax.swing.JPanel { this.chatPanel.disconnect(); this.players.clear(); this.pnlBattlefield.removeAll(); - + this.combat.hideDialog(); this.setVisible(false); } - public void init(GameView game) { + public synchronized void init(GameView game) { combat.init(gameId, bigCard); MageFrame.getDesktop().add(combat, JLayeredPane.PALETTE_LAYER); this.players.clear(); @@ -144,7 +144,7 @@ public class GamePanel extends javax.swing.JPanel { updateGame(game); } - public void updateGame(GameView game) { + public synchronized void updateGame(GameView game) { if (game.getHand() != null) this.hand.loadCards(game.getHand(), bigCard, gameId); else @@ -169,6 +169,7 @@ public class GamePanel extends javax.swing.JPanel { } if (game.getCombat().size() > 0) { combat.showDialog(game.getCombat()); + combat.setLocation(300, 200); } else { combat.hideDialog(); diff --git a/Mage.Client/src/mage/client/remote/Session.java b/Mage.Client/src/mage/client/remote/Session.java index 0ddd39baeac..2ed6cb77ac9 100644 --- a/Mage.Client/src/mage/client/remote/Session.java +++ b/Mage.Client/src/mage/client/remote/Session.java @@ -40,12 +40,12 @@ import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; -import mage.Constants; import mage.cards.decks.DeckCardLists; import mage.client.MageFrame; import mage.client.chat.ChatPanel; import mage.client.game.GamePanel; import mage.client.util.Config; +import mage.game.GameException; import mage.interfaces.MageException; import mage.interfaces.Server; import mage.interfaces.callback.CallbackClientDaemon; @@ -67,6 +67,7 @@ public class Session { private MageFrame frame; private String[] playerTypes; private String[] gameTypes; + private String[] deckTypes; private Map chats = new HashMap(); private GamePanel game; private CallbackClientDaemon callbackDaemon; @@ -89,7 +90,9 @@ public class Session { callbackDaemon = new CallbackClientDaemon(sessionId, client, server); playerTypes = server.getPlayerTypes(); gameTypes = server.getGameTypes(); + deckTypes = server.getDeckTypes(); logger.info("Connected to RMI server at " + serverName + ":" + port); + frame.setStatusText("Connected to " + serverName + ":" + port); frame.enableButtons(); } catch (MageException ex) { Logger.getLogger(Session.class.getName()).log(Level.SEVERE, null, ex); @@ -112,6 +115,7 @@ public class Session { } catch (MageException ex) { logger.log(Level.SEVERE, "Error disconnecting ...", ex); } + frame.setStatusText("Not connected"); } } @@ -127,6 +131,10 @@ public class Session { return gameTypes; } + public String[] getDeckTypes() { + return deckTypes; + } + public Map getChats() { return chats; } @@ -225,6 +233,8 @@ public class Session { handleRemoteException(ex); } catch (MageException ex) { handleMageException(ex); + } catch (GameException ex) { + handleGameException(ex); } return false; } @@ -363,7 +373,7 @@ public class Session { return false; } - public TableView createTable(UUID roomId, String gameType, Constants.DeckType deckType, List playerTypes) { + public TableView createTable(UUID roomId, String gameType, String deckType, List playerTypes) { try { return server.createTable(sessionId, roomId, gameType, deckType, playerTypes); } catch (RemoteException ex) { @@ -496,6 +506,7 @@ public class Session { private void handleRemoteException(RemoteException ex) { server = null; logger.log(Level.SEVERE, "Connection to server lost", ex); + frame.setStatusText("Not connected"); JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Connection to server lost.", "Error", JOptionPane.ERROR_MESSAGE); frame.disableButtons(); } @@ -507,6 +518,12 @@ public class Session { frame.disableButtons(); } + private void handleGameException(GameException ex) { + logger.log(Level.WARNING, "Game error", ex.getMessage()); + JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + + public String getUserName() { return userName; } diff --git a/Mage.Client/src/mage/client/util/EDTExceptionHandler.java b/Mage.Client/src/mage/client/util/EDTExceptionHandler.java index 6321af56f60..abc5e3d89e7 100644 --- a/Mage.Client/src/mage/client/util/EDTExceptionHandler.java +++ b/Mage.Client/src/mage/client/util/EDTExceptionHandler.java @@ -28,7 +28,10 @@ package mage.client.util; +import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.JOptionPane; +import mage.client.MageFrame; import mage.util.Logging; /** @@ -46,7 +49,8 @@ public class EDTExceptionHandler implements Thread.UncaughtExceptionHandler { public void handle(Throwable throwable) { try { - logger.severe(throwable.getMessage()); + logger.log(Level.SEVERE, null, throwable); + JOptionPane.showMessageDialog(MageFrame.getDesktop(), throwable, "MAGE Client UI error", JOptionPane.ERROR_MESSAGE); } catch (Throwable t) {} } diff --git a/Mage.Client/src/mage/client/util/Frames.java b/Mage.Client/src/mage/client/util/Frames.java index f37b524a878..30a32bd642f 100644 --- a/Mage.Client/src/mage/client/util/Frames.java +++ b/Mage.Client/src/mage/client/util/Frames.java @@ -44,12 +44,23 @@ public class Frames { public static Image Grey = ImageHelper.loadImage(Config.frameResourcePath + "8 grey.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); public static Image Red = ImageHelper.loadImage(Config.frameResourcePath + "8 red.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); public static Image White = ImageHelper.loadImage(Config.frameResourcePath + "8 white.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); + public static Image BlackRed = ImageHelper.loadImage(Config.frameResourcePath + "black to red hybrid.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); + public static Image BlackGreen = ImageHelper.loadImage(Config.frameResourcePath + "eve hybrid black to green.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); + public static Image BlueBlack = ImageHelper.loadImage(Config.frameResourcePath + "blue_to_black_hybrid.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); + public static Image BlueRed = ImageHelper.loadImage(Config.frameResourcePath + "eve hybrid blue to red.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); + public static Image GreenBlue = ImageHelper.loadImage(Config.frameResourcePath + "eve hybrid green to blue.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); + public static Image GreenWhite = ImageHelper.loadImage(Config.frameResourcePath + "green_to_white_hybrid.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); + public static Image RedGreen = ImageHelper.loadImage(Config.frameResourcePath + "red_to_green_hybrid.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); + public static Image RedWhite = ImageHelper.loadImage(Config.frameResourcePath + "eve hybrid red to white.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); + public static Image WhiteBlack = ImageHelper.loadImage(Config.frameResourcePath + "eve hybrid white to black.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); + public static Image WhiteBlue = ImageHelper.loadImage(Config.frameResourcePath + "white_to_blue_hybrid.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); public static Image Forest = ImageHelper.loadImage(Config.frameResourcePath + "8 land mana green.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); public static Image Island = ImageHelper.loadImage(Config.frameResourcePath + "8 land mana blue.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); public static Image Mountain = ImageHelper.loadImage(Config.frameResourcePath + "8 land mana red.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); public static Image Plains = ImageHelper.loadImage(Config.frameResourcePath + "8 land mana white.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); public static Image Swamp = ImageHelper.loadImage(Config.frameResourcePath + "8 land mana black.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); + public static Image Land = ImageHelper.loadImage(Config.frameResourcePath + "8 multiland nomana colorless.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); public static Image Effect = ImageHelper.loadImage(Config.frameResourcePath + "Effects\\effect0.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); diff --git a/Mage.Client/src/mage/client/util/ImageHelper.java b/Mage.Client/src/mage/client/util/ImageHelper.java index 9580045d648..92ee8ec3dd9 100644 --- a/Mage.Client/src/mage/client/util/ImageHelper.java +++ b/Mage.Client/src/mage/client/util/ImageHelper.java @@ -41,6 +41,7 @@ import java.util.HashMap; import java.util.List; import javax.imageio.ImageIO; import mage.Constants.CardType; +import mage.view.AbilityView; import mage.view.CardView; import mage.view.StackAbilityView; import static mage.client.util.Constants.*; @@ -87,12 +88,12 @@ public class ImageHelper { g.setColor(Color.WHITE); g.fillRect(0, 0, FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT); g.drawImage(getFrame(card), 0, 0, Color.WHITE, null); - if (!card.getArt().equals("")) { + if (card.getArt() != null && !card.getArt().equals("")) { Image art = loadImage(Config.cardArtResourcePath + card.getArt(), ART_MAX_WIDTH, ART_MAX_HEIGHT); g.drawImage(art, CONTENT_MAX_XOFFSET, ART_MAX_YOFFSET, null); } - if (card.getCardTypes().contains(CardType.CREATURE) || card.getCardTypes().contains(CardType.PLANESWALKER)) { + if (card.getCardTypes() != null && (card.getCardTypes().contains(CardType.CREATURE) || card.getCardTypes().contains(CardType.PLANESWALKER))) { g.drawImage(Frames.PowBoxLeft, POWBOX_MAX_LEFT, POWBOX_MAX_TOP, null); g.drawImage(Frames.PowBoxMid, POWBOX_MAX_LEFT + 7, POWBOX_MAX_TOP, null); g.drawImage(Frames.PowBoxRight, POWBOX_MAX_LEFT + 38, POWBOX_MAX_TOP, null); @@ -105,7 +106,7 @@ public class ImageHelper { } protected static Image getFrame(CardView card) { - if (card instanceof StackAbilityView) { + if (card instanceof StackAbilityView || card instanceof AbilityView) { return Frames.Effect; } @@ -116,6 +117,48 @@ public class ImageHelper { if (card.getColor().isColorless()) { return Frames.Grey; } else if (card.getColor().isMulticolored()) { + if (card.getColor().getColorCount() > 2) + return Frames.Gold; + if (card.getColor().isBlack() && card.getColor().isRed()) { + if (Frames.BlackRed != null) + return Frames.BlackRed; + } + else if (card.getColor().isBlack() && card.getColor().isGreen()) { + if (Frames.BlackGreen != null) + return Frames.BlackGreen; + } + else if (card.getColor().isBlack() && card.getColor().isBlue()) { + if (Frames.BlueBlack != null) + return Frames.BlueBlack; + } + else if (card.getColor().isRed() && card.getColor().isBlue()) { + if (Frames.BlueRed != null) + return Frames.BlueRed; + } + else if (card.getColor().isGreen() && card.getColor().isBlue()) { + if (Frames.GreenBlue != null) + return Frames.GreenBlue; + } + else if (card.getColor().isGreen() && card.getColor().isWhite()) { + if (Frames.GreenWhite != null) + return Frames.GreenWhite; + } + else if (card.getColor().isRed() && card.getColor().isGreen()) { + if (Frames.RedGreen != null) + return Frames.RedGreen; + } + else if (card.getColor().isRed() && card.getColor().isWhite()) { + if (Frames.RedWhite != null) + return Frames.RedWhite; + } + else if (card.getColor().isWhite() && card.getColor().isBlack()) { + if (Frames.WhiteBlack != null) + return Frames.WhiteBlack; + } + else if (card.getColor().isWhite() && card.getColor().isBlue()) { + if (Frames.WhiteBlue != null) + return Frames.WhiteBlue; + } return Frames.Gold; } else { if (card.getColor().isBlack()) { @@ -152,7 +195,7 @@ public class ImageHelper { return Frames.Swamp; } } - return Frames.Grey; + return Frames.Land; } public static Image ScaleImage(Image image, int width, int height) {