diff --git a/Mage.Client/plugins/mage-card-plugin.jar b/Mage.Client/plugins/mage-card-plugin.jar index 1ad58bba6e..1f94aabff6 100644 Binary files a/Mage.Client/plugins/mage-card-plugin.jar and b/Mage.Client/plugins/mage-card-plugin.jar differ diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java b/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java index 6ed8cc69e0..d9eef52164 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java @@ -43,11 +43,14 @@ import mage.client.util.Event; import mage.client.util.Listener; import mage.components.CardInfoPane; import mage.game.GameException; +import mage.view.CardView; import mage.view.CardsView; import javax.swing.*; import javax.swing.filechooser.FileFilter; import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; import java.lang.reflect.Constructor; @@ -98,7 +101,7 @@ public class DeckEditorPanel extends javax.swing.JPanel { cardSelector.getCardsList().removeCard(card.getId()); } if (cardInfoPane instanceof CardInfoPane) { - ((CardInfoPane)cardInfoPane).setCard(card); + ((CardInfoPane)cardInfoPane).setCard(new CardView(card)); } break; } @@ -178,7 +181,7 @@ public class DeckEditorPanel extends javax.swing.JPanel { cardInfoPane = Plugins.getInstance().getCardInfoPane(); if (cardInfoPane != null && System.getProperty("testCardInfo") != null) { - cardInfoPane.setPreferredSize(new Dimension(170,230)); + cardInfoPane.setPreferredSize(new Dimension(170,150)); cardInfoPane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); isShowCardInfo = true; } else { @@ -456,4 +459,6 @@ class ImportFilter extends FileFilter { public String getDescription() { return "*.dec | *.mwDeck | *.txt"; } + + } \ No newline at end of file diff --git a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java index b4eb379e81..00cc13b3b7 100644 --- a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java +++ b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java @@ -1,16 +1,13 @@ package mage.client.plugins.adapters; -import java.awt.Color; -import java.awt.Image; -import java.awt.Point; +import java.awt.*; +import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.util.List; import java.util.UUID; -import javax.swing.Popup; -import javax.swing.PopupFactory; -import javax.swing.SwingUtilities; +import javax.swing.*; import mage.cards.MageCard; import mage.cards.MagePermanent; @@ -25,6 +22,8 @@ import mage.client.util.DefaultActionCallback; import mage.client.util.ImageHelper; import mage.client.util.gui.ArrowBuilder; import mage.client.util.gui.GuiDisplayUtil; +import mage.components.CardInfoPane; +import mage.utils.ThreadUtils; import mage.view.CardView; import org.jdesktop.swingx.JXPanel; @@ -32,12 +31,14 @@ import org.jdesktop.swingx.JXPanel; public class MageActionCallback implements ActionCallback { private Popup popup; + private JPopupMenu jPopupMenu; private BigCard bigCard; protected static DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance(); protected static Session session = MageFrame.getSession(); private CardView popupCard; private Thread t; private int state = 0; + private JComponent cardInfoPane; public MageActionCallback() { } @@ -50,6 +51,9 @@ public class MageActionCallback implements ActionCallback { if (session == null) { session = MageFrame.getSession(); } + if (cardInfoPane == null) { + cardInfoPane = Plugins.getInstance().getCardInfoPane(); + } } @Override @@ -125,15 +129,44 @@ public class MageActionCallback implements ActionCallback { } catch (InterruptedException ie) { ie.printStackTrace(); }*/ - - PopupFactory factory = PopupFactory.getSharedInstance(); - popup = factory.getPopup(data.component, data.popupText, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40); - popup.show(); - // hack to get popup to resize to fit text - popup.hide(); - popup = factory.getPopup(data.component, data.popupText, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40); - popup.show(); - } + + if (cardInfoPane == null) { + PopupFactory factory = PopupFactory.getSharedInstance(); + popup = factory.getPopup(data.component, data.popupText, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40); + popup.show(); + // hack to get popup to resize to fit text + popup.hide(); + popup = factory.getPopup(data.component, data.popupText, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40); + popup.show(); + } else { + + ThreadUtils.threadPool2.submit(new Runnable() { + @Override + public void run() { + ThreadUtils.threadPool2.submit(new Runnable() { + @Override + public void run() { + try { + Thread.sleep(900); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + if (!popupCard.equals(data.card)) { + return; + } + PopupFactory factory = PopupFactory.getSharedInstance(); + ((CardInfoPane)cardInfoPane).setCard(data.card); + cardInfoPane.setSize(161, 221); + cardInfoPane.setPreferredSize(new Dimension(161, 221)); + popup = factory.getPopup(data.component, cardInfoPane, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40); + popup.show(); + } + }); + } + }); + + } + } @Override public void mouseMoved(MouseEvent e, TransferData data) { @@ -172,6 +205,9 @@ public class MageActionCallback implements ActionCallback { if (popup != null) { popup.hide(); } + if (jPopupMenu != null) { + jPopupMenu.setVisible(false); + } ArrowBuilder.removeAllArrows(); } diff --git a/Mage.Common/src/mage/components/CardInfoPane.java b/Mage.Common/src/mage/components/CardInfoPane.java index 19b1047ca2..ca3d269c28 100644 --- a/Mage.Common/src/mage/components/CardInfoPane.java +++ b/Mage.Common/src/mage/components/CardInfoPane.java @@ -1,6 +1,7 @@ package mage.components; import mage.cards.Card; +import mage.view.CardView; /** * Card info pane for displaying card rules. @@ -9,6 +10,6 @@ import mage.cards.Card; * @author nantuko */ public interface CardInfoPane { - public void setCard (final Card card); - public boolean isCurrentCard (Card card); + public void setCard (final CardView card); + public boolean isCurrentCard (CardView card); } diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ThreadUtils.java b/Mage.Common/src/mage/utils/ThreadUtils.java similarity index 67% rename from Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ThreadUtils.java rename to Mage.Common/src/mage/utils/ThreadUtils.java index 4df8c5a0d2..0f321f0d8a 100644 --- a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ThreadUtils.java +++ b/Mage.Common/src/mage/utils/ThreadUtils.java @@ -1,4 +1,4 @@ -package org.mage.card.arcane; +package mage.utils; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; @@ -13,6 +13,7 @@ import java.util.concurrent.TimeUnit; public class ThreadUtils { static public ThreadPoolExecutor threadPool; + static public ThreadPoolExecutor threadPool2; static private int threadCount; static { threadPool = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() { @@ -24,6 +25,15 @@ public class ThreadUtils { } }); threadPool.prestartAllCoreThreads(); + threadPool2 = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() { + public Thread newThread (Runnable runnable) { + threadCount++; + Thread thread = new Thread(runnable, "TP2" + threadCount); + thread.setDaemon(true); + return thread; + } + }); + threadPool2.prestartAllCoreThreads(); } static public void sleep (int millis) { diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ManaSymbols.java b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ManaSymbols.java index 932e57bd15..9ca2ca45bf 100644 --- a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ManaSymbols.java +++ b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ManaSymbols.java @@ -84,10 +84,10 @@ public class ManaSymbols { static public synchronized String replaceSymbolsWithHTML (String value, boolean small) { if (small) - return replaceSymbolsPattern.matcher(value).replaceAll(""); + return replaceSymbolsPattern.matcher(value).replaceAll("$1$2"); else { - value = value.replace("{slash}", ""); - return replaceSymbolsPattern.matcher(value).replaceAll(""); + value = value.replace("{slash}", "slash"); + return replaceSymbolsPattern.matcher(value).replaceAll("$1$2"); } } } diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/info/CardInfoPaneImpl.java b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/info/CardInfoPaneImpl.java index e13fd59aa9..747c84d871 100644 --- a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/info/CardInfoPaneImpl.java +++ b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/info/CardInfoPaneImpl.java @@ -1,11 +1,11 @@ package org.mage.plugins.card.info; import mage.Constants; -import mage.cards.Card; import mage.components.CardInfoPane; import mage.utils.CardUtil; +import mage.utils.ThreadUtils; +import mage.view.CardView; import org.mage.card.arcane.ManaSymbols; -import org.mage.card.arcane.ThreadUtils; import org.mage.card.arcane.UI; import javax.swing.*; @@ -20,15 +20,16 @@ import java.util.List; */ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane { - private Card currentCard; + private CardView currentCard; public CardInfoPaneImpl() { UI.setHTMLEditorKit(this); setEditable(false); setBackground(Color.white); + setSize(170, Integer.MAX_VALUE); } - public void setCard (final Card card) { + public void setCard (final CardView card) { if (card == null) return; if (isCurrentCard(card)) return; currentCard = card; @@ -37,7 +38,11 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane { public void run () { if (!card.equals(currentCard)) return; - String castingCost = UI.getDisplayManaCost(card.getManaCost().getText()); + String manaCost = ""; + for (String m : card.getManaCost()) { + manaCost += m; + } + String castingCost = UI.getDisplayManaCost(manaCost); castingCost = ManaSymbols.replaceSymbolsWithHTML(castingCost, false); int symbolCount = 0; @@ -111,13 +116,13 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane { } String pt = ""; - if (card.getCardType().contains(Constants.CardType.CREATURE)) { + if (CardUtil.isCreature(card)) { pt = card.getPower() + "/" + card.getToughness(); - } else if (card.getCardType().contains(Constants.CardType.PLANESWALKER)) { + } else if (CardUtil.isPlaneswalker(card)) { pt = card.getLoyalty().toString(); } if (pt.length() > 0) { - buffer.append("
"); + buffer.append("
"); buffer.append(""); buffer.append(""); buffer.append(pt); @@ -131,7 +136,7 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane { public void run () { if (!card.equals(currentCard)) return; setText(buffer.toString()); - System.out.println(buffer.toString()); + //System.out.println(buffer.toString()); setCaretPosition(0); } }); @@ -139,24 +144,24 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane { }); } - private String getTypes(Card card) { + private String getTypes(CardView card) { String types = ""; - for (String superType : card.getSupertype()) { + for (String superType : card.getSuperTypes()) { types += superType + " "; } - for (Constants.CardType cardType : card.getCardType()) { + for (Constants.CardType cardType : card.getCardTypes()) { types += cardType.toString() + " "; } - if (card.getSubtype().size() > 0) { + if (card.getSubTypes().size() > 0) { types += "- "; } - for (String subType : card.getSubtype()) { + for (String subType : card.getSubTypes()) { types += subType + " "; } return types.trim(); } - public boolean isCurrentCard (Card card) { + public boolean isCurrentCard (CardView card) { return currentCard != null && card.equals(currentCard); } }