diff --git a/Mage.Client/plugins/Mage-Theme-Plugin-0.3-shaded.jar b/Mage.Client/plugins/Mage-Theme-Plugin-0.3-shaded.jar deleted file mode 100644 index 5304fdbc23..0000000000 Binary files a/Mage.Client/plugins/Mage-Theme-Plugin-0.3-shaded.jar and /dev/null differ diff --git a/Mage.Client/pom.xml b/Mage.Client/pom.xml index c7a89350f9..76158ee4df 100644 --- a/Mage.Client/pom.xml +++ b/Mage.Client/pom.xml @@ -42,6 +42,11 @@ <artifactId>log4j</artifactId> <version>1.2.9</version> </dependency> + <dependency> + <groupId>com.mortennobel</groupId> + <artifactId>java-image-scaling</artifactId> + <version>0.8.4</version> + </dependency> </dependencies> <build> diff --git a/Mage.Client/src/main/java/mage/client/cards/BigCard.java b/Mage.Client/src/main/java/mage/client/cards/BigCard.java index 111c447b12..ad4cf1b399 100644 --- a/Mage.Client/src/main/java/mage/client/cards/BigCard.java +++ b/Mage.Client/src/main/java/mage/client/cards/BigCard.java @@ -53,10 +53,14 @@ public class BigCard extends javax.swing.JPanel { protected Image bigImage; protected UUID cardId; - public BigCard() { + public BigCard() { initComponents(); } + public void removeTextComponent() { + remove(this.scrollPane); + } + public void setCard(UUID cardId, Image image, List<String> strings) { if (this.cardId == null || !this.cardId.equals(cardId)) { this.cardId = cardId; @@ -66,6 +70,10 @@ public class BigCard extends javax.swing.JPanel { } } + public UUID getCardId() { + return cardId; + } + private void drawText(java.util.List<String> strings) { text.setText(""); StyledDocument doc = text.getStyledDocument(); diff --git a/Mage.Client/src/main/java/mage/client/cards/Card.java b/Mage.Client/src/main/java/mage/client/cards/Card.java index 6eb9af060a..3c35cd63f0 100644 --- a/Mage.Client/src/main/java/mage/client/cards/Card.java +++ b/Mage.Client/src/main/java/mage/client/cards/Card.java @@ -50,6 +50,7 @@ import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.Image; import java.awt.Point; import java.awt.Rectangle; import java.awt.RenderingHints; @@ -97,7 +98,7 @@ import mage.view.StackAbilityView; public class Card extends MagePermanent implements MouseMotionListener, MouseListener, FocusListener, ComponentListener { protected static Session session = MageFrame.getSession(); - protected static DefaultActionCallback callback = new DefaultActionCallback(); + protected static DefaultActionCallback callback = DefaultActionCallback.getInstance(); protected Point p; protected CardDimensions dimension; @@ -469,4 +470,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis public void setCardBounds(int x, int y, int width, int height) { throw new RuntimeException("Not implemented"); } + + @Override + public Image getImage() { + return image; + } } diff --git a/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java b/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java index fcebc74280..aa2b2fed67 100644 --- a/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java @@ -36,9 +36,14 @@ package mage.client.game; import java.awt.Component; import java.awt.Dimension; +import java.awt.Image; import java.awt.Rectangle; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import java.awt.image.BufferedImage; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -49,11 +54,16 @@ import javax.swing.JComponent; import javax.swing.JScrollPane; import mage.cards.MagePermanent; +import mage.client.MageFrame; import mage.client.cards.BigCard; +import mage.client.cards.Card; import mage.client.cards.Permanent; +import mage.client.plugins.adapters.MageMouseAdapter; +import mage.client.plugins.adapters.MageMouseMotionAdapter; import mage.client.plugins.impl.Plugins; import mage.client.util.Config; import mage.client.util.DefaultActionCallback; +import mage.client.util.ImageHelper; import mage.view.PermanentView; /** @@ -66,61 +76,32 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane implements Compon private UUID gameId; private BigCard bigCard; private Map<String, JComponent> ui = new HashMap<String, JComponent>(); - - //TODO: made it singleton - protected static DefaultActionCallback defaultCallback = new DefaultActionCallback(); + + protected static DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance(); /** Creates new form BattlefieldPanel */ public BattlefieldPanel(JScrollPane jScrollPane) { ui.put("jScrollPane", jScrollPane); + ui.put("battlefieldPanel", this); initComponents(); - - /*addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if (e.getButton() == MouseEvent.BUTTON1) { - int count = e.getClickCount(); - //System.out.println("pressed"); - if (count > 0) { - Object o = getComponentAt(e.getPoint()); - //System.out.println("obj="+o); - //System.out.println("e: "+e.getX()); - if (o instanceof MagePermanent) { - System.out.println("ok"); - MagePermanent selectedCard = (MagePermanent) o; - //TODO: uncomment when attached cards works in plugin - /* - int x = e.getX() - selectedCard.getX(); - int y = e.getY() - selectedCard.getY(); - CardView card = selectedCard.getCardByPosition(x, y); - */ - /*defaultCallback.mouseClicked(e, gameId, MageFrame.getSession(), selectedCard.getOriginal()); - } - } - } - } - @Override - public void mouseMoved(MouseEvent e) { - System.out.println("e: "+e.getX()); - Object o = getComponentAt(e.getPoint()); - if (o instanceof MagePermanent) { - MagePermanent card = (MagePermanent) o; - System.out.println("card: "+card.getOriginal().getId()); - bigCard.setCard(card.getOriginal().getId(), null, card.getOriginal().getRules()); - } - } - });*/ + addMouseListener(new MageMouseAdapter(this, gameId)); + addMouseMotionListener(new MageMouseMotionAdapter(this, bigCard)); } public void init(UUID gameId, BigCard bigCard) { this.gameId = gameId; this.bigCard = bigCard; + if (Plugins.getInstance().isCardPluginLoaded()) { + bigCard.removeTextComponent(); + } } public void update(Map<UUID, PermanentView> battlefield) { for (PermanentView permanent: battlefield.values()) { if (!permanents.containsKey(permanent.getId())) { + //TODO: remove me + //System.out.println("Add permanent: " + permanent.getCardNumber()); addPermanent(permanent); } else { diff --git a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageMouseAdapter.java b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageMouseAdapter.java new file mode 100644 index 0000000000..a8738c2cc3 --- /dev/null +++ b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageMouseAdapter.java @@ -0,0 +1,45 @@ +package mage.client.plugins.adapters; + +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.UUID; + +import mage.cards.MagePermanent; +import mage.client.MageFrame; +import mage.client.plugins.impl.Plugins; +import mage.client.util.DefaultActionCallback; + +public class MageMouseAdapter extends MouseAdapter { + + private Component parent; + private UUID gameId; + protected static DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance(); + + public MageMouseAdapter(Component parent, UUID gameId) { + this.parent = parent; + this.gameId = gameId; + } + + @Override + public void mousePressed(MouseEvent e) { + if (!Plugins.getInstance().isCardPluginLoaded()) + return; + if (e.getButton() == MouseEvent.BUTTON1) { + int count = e.getClickCount(); + if (count > 0) { + Object o = parent.getComponentAt(e.getPoint()); + if (o instanceof MagePermanent) { + MagePermanent selectedCard = (MagePermanent) o; + // TODO: uncomment when attached cards works in plugin + /* + * int x = e.getX() - selectedCard.getX(); int y = e.getY() + * - selectedCard.getY(); CardView card = + * selectedCard.getCardByPosition(x, y); + */ + defaultCallback.mouseClicked(e, gameId, MageFrame.getSession(), selectedCard.getOriginal()); + } + } + } + } +} diff --git a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageMouseMotionAdapter.java b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageMouseMotionAdapter.java new file mode 100644 index 0000000000..efa2d8b942 --- /dev/null +++ b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageMouseMotionAdapter.java @@ -0,0 +1,41 @@ +package mage.client.plugins.adapters; + +import java.awt.Component; +import java.awt.Image; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import java.awt.image.BufferedImage; + +import mage.cards.MagePermanent; +import mage.client.cards.BigCard; +import mage.client.plugins.impl.Plugins; +import mage.client.util.ImageHelper; + +public class MageMouseMotionAdapter extends MouseMotionAdapter { + + private Component parent; + private BigCard bigCard; + + public MageMouseMotionAdapter(Component parent, BigCard bigCard) { + this.parent = parent; + this.bigCard = bigCard; + } + + @Override + public void mouseMoved(MouseEvent e) { + if (!Plugins.getInstance().isCardPluginLoaded()) return; + Object o = parent.getComponentAt(e.getPoint()); + if (o instanceof MagePermanent) { + MagePermanent card = (MagePermanent) o; + if (card.getOriginal().getId() != bigCard.getCardId()) { + Image image = card.getImage(); + if (image != null && image instanceof BufferedImage) { + image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth(), bigCard.getHeight()); + bigCard.setCard(card.getOriginal().getId(), image, card.getOriginal().getRules()); + } else { + //TODO: add description panel + } + } + } + } +} diff --git a/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java b/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java index 6b643a8e10..00d4c594bf 100644 --- a/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java +++ b/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java @@ -1,6 +1,5 @@ package mage.client.plugins.impl; -import java.awt.event.MouseEvent; import java.io.File; import java.util.Collection; import java.util.Map; @@ -12,12 +11,10 @@ import javax.swing.JComponent; import mage.cards.CardDimensions; import mage.cards.MagePermanent; -import mage.cards.interfaces.ActionCallback; -import mage.client.MageFrame; +import mage.cards.action.impl.EmptyCallback; import mage.client.cards.BigCard; import mage.client.cards.Permanent; import mage.client.plugins.MagePlugins; -import mage.client.remote.Session; import mage.client.util.Config; import mage.client.util.DefaultActionCallback; import mage.constants.Constants; @@ -36,7 +33,8 @@ public class Plugins implements MagePlugins { private static PluginManager pm; private final static Logger logger = Logging.getLogger(Plugins.class.getName()); private CardPlugin cardPlugin = null; - protected static DefaultActionCallback defaultCallback = new DefaultActionCallback(); + protected static DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance(); + private static final EmptyCallback emptyCallback = new EmptyCallback(); public static MagePlugins getInstance() { return fINSTANCE; @@ -68,16 +66,7 @@ public class Plugins implements MagePlugins { @Override public MagePermanent getMagePermanent(final PermanentView card, BigCard bigCard, CardDimensions dimension, final UUID gameId) { if (cardPlugin != null) { - return cardPlugin.getMagePermanent(card, dimension, gameId, new ActionCallback() { - @Override - public void mouseClicked(MouseEvent e) { - //defaultCallback.mouseClicked(e, gameId, MageFrame.getSession(), card); - } - @Override - public void mouseMoved(MouseEvent e) { - //defaultCallback.mouseClicked(e, gameId, MageFrame.getSession(), card); - } - }); + return cardPlugin.getMagePermanent(card, dimension, gameId, emptyCallback); } else { return new Permanent(card, bigCard, Config.dimensions, gameId); } diff --git a/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java b/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java index d898b554ec..068e595e08 100644 --- a/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java +++ b/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java @@ -8,6 +8,15 @@ import mage.view.CardView; public class DefaultActionCallback { + + private static final DefaultActionCallback INSTANCE = new DefaultActionCallback(); + + private DefaultActionCallback() {} + + public static DefaultActionCallback getInstance() { + return INSTANCE; + } + public void mouseClicked(MouseEvent e, UUID gameId, Session session, CardView card) { System.out.println("gameId:" + gameId); if (gameId != null) diff --git a/Mage.Client/src/main/java/mage/client/util/ImageHelper.java b/Mage.Client/src/main/java/mage/client/util/ImageHelper.java index 2c4cd64797..06f09367b8 100644 --- a/Mage.Client/src/main/java/mage/client/util/ImageHelper.java +++ b/Mage.Client/src/main/java/mage/client/util/ImageHelper.java @@ -52,6 +52,8 @@ import mage.view.AbilityView; import mage.view.CardView; import mage.view.StackAbilityView; +import com.mortennobel.imagescaling.ResampleOp; + /** * * @author BetaSteward_at_googlemail.com @@ -299,4 +301,14 @@ public class ImageHelper { } } + /** + * Returns an image scaled to the size appropriate for the card picture + * panel + */ + public static BufferedImage getResizedImage(BufferedImage original, int width, int height) { + ResampleOp resampleOp = new ResampleOp(width, height); + BufferedImage image = resampleOp.filter(original, null); + return image; + } + } diff --git a/Mage.Client/src/main/resources/dk_gray.jpg b/Mage.Client/src/main/resources/dk_gray.jpg deleted file mode 100644 index 2e0776d606..0000000000 Binary files a/Mage.Client/src/main/resources/dk_gray.jpg and /dev/null differ diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/resources/log4j.properties b/Mage.Client/src/main/resources/log4j.properties similarity index 100% rename from Mage.Plugins/Mage.Card.Plugin/src/main/resources/log4j.properties rename to Mage.Client/src/main/resources/log4j.properties diff --git a/Mage.Common/src/mage/cards/MagePermanent.java b/Mage.Common/src/mage/cards/MagePermanent.java index 6052ef23d4..74fe2fd446 100644 --- a/Mage.Common/src/mage/cards/MagePermanent.java +++ b/Mage.Common/src/mage/cards/MagePermanent.java @@ -1,13 +1,13 @@ package mage.cards; +import java.awt.Image; import java.util.List; import javax.swing.JPanel; -import mage.cards.interfaces.PermanentInterface; import mage.view.PermanentView; -public abstract class MagePermanent extends JPanel implements PermanentInterface { +public abstract class MagePermanent extends JPanel { private static final long serialVersionUID = -3469258620601702171L; abstract public List<MagePermanent> getLinks(); @@ -17,4 +17,6 @@ public abstract class MagePermanent extends JPanel implements PermanentInterface abstract public void setAlpha(float transparency); abstract public PermanentView getOriginal(); abstract public void setCardBounds(int x, int y, int width, int height); + abstract public void update(PermanentView card); + abstract public Image getImage(); } diff --git a/Mage.Common/src/mage/cards/interfaces/ActionCallback.java b/Mage.Common/src/mage/cards/action/ActionCallback.java similarity index 77% rename from Mage.Common/src/mage/cards/interfaces/ActionCallback.java rename to Mage.Common/src/mage/cards/action/ActionCallback.java index e1e2d2c748..6e9667146c 100644 --- a/Mage.Common/src/mage/cards/interfaces/ActionCallback.java +++ b/Mage.Common/src/mage/cards/action/ActionCallback.java @@ -1,4 +1,4 @@ -package mage.cards.interfaces; +package mage.cards.action; import java.awt.event.MouseEvent; diff --git a/Mage.Common/src/mage/cards/action/impl/EmptyCallback.java b/Mage.Common/src/mage/cards/action/impl/EmptyCallback.java new file mode 100644 index 0000000000..11b66acca5 --- /dev/null +++ b/Mage.Common/src/mage/cards/action/impl/EmptyCallback.java @@ -0,0 +1,22 @@ +package mage.cards.action.impl; + +import java.awt.event.MouseEvent; + +import mage.cards.action.ActionCallback; + +/** + * Callback that does nothing on any action + * + * @author nantuko84 + */ +public class EmptyCallback implements ActionCallback { + + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mouseMoved(MouseEvent e) { + } + +} diff --git a/Mage.Common/src/mage/cards/interfaces/PermanentInterface.java b/Mage.Common/src/mage/cards/interfaces/PermanentInterface.java deleted file mode 100644 index c26433808a..0000000000 --- a/Mage.Common/src/mage/cards/interfaces/PermanentInterface.java +++ /dev/null @@ -1,7 +0,0 @@ -package mage.cards.interfaces; - -import mage.view.PermanentView; - -public interface PermanentInterface { - void update(PermanentView card); -} diff --git a/Mage.Common/src/mage/interfaces/plugin/CardPlugin.java b/Mage.Common/src/mage/interfaces/plugin/CardPlugin.java index 4ae2490499..584f611ffd 100644 --- a/Mage.Common/src/mage/interfaces/plugin/CardPlugin.java +++ b/Mage.Common/src/mage/interfaces/plugin/CardPlugin.java @@ -8,7 +8,7 @@ import javax.swing.JComponent; import mage.cards.CardDimensions; import mage.cards.MagePermanent; -import mage.cards.interfaces.ActionCallback; +import mage.cards.action.ActionCallback; import mage.view.PermanentView; import net.xeoh.plugins.base.Plugin; diff --git a/Mage.Common/src/mage/view/CardView.java b/Mage.Common/src/mage/view/CardView.java index aa7f009748..80415d0331 100644 --- a/Mage.Common/src/mage/view/CardView.java +++ b/Mage.Common/src/mage/view/CardView.java @@ -96,6 +96,8 @@ public class CardView implements Serializable { this.rarity = card.getRarity(); this.expansionSetCode = card.getExpansionSetCode(); } + //TODO:remove me + //System.out.println("**** CARD NUMBER **** : " + card.getCardNumber() + " : " + card.getName() + " : " + card.getExpansionSetCode()); this.cardNumber = card.getCardNumber(); if (card instanceof Spell) { diff --git a/Mage.Plugins/Mage.Card.Plugin/pom.xml b/Mage.Plugins/Mage.Card.Plugin/pom.xml index 71fd30f5b9..5a674465c5 100644 --- a/Mage.Plugins/Mage.Card.Plugin/pom.xml +++ b/Mage.Plugins/Mage.Card.Plugin/pom.xml @@ -31,6 +31,7 @@ <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.9</version> + <scope>provided</scope> </dependency> </dependencies> diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/CardPanel.java b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/CardPanel.java index 336f0025fc..606b3ae73c 100644 --- a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/CardPanel.java +++ b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/CardPanel.java @@ -10,9 +10,6 @@ import java.awt.Image; import java.awt.Point; import java.awt.Rectangle; import java.awt.RenderingHints; -import java.awt.event.ComponentEvent; -import java.awt.event.FocusEvent; -import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.io.IOException; import java.util.ArrayList; @@ -24,7 +21,7 @@ import javax.swing.JRootPane; import javax.swing.SwingUtilities; import mage.cards.MagePermanent; -import mage.cards.interfaces.ActionCallback; +import mage.cards.action.ActionCallback; import mage.utils.CardUtil; import mage.view.PermanentView; @@ -132,10 +129,8 @@ public class CardPanel extends MagePermanent { tappedAngle = gameCard.isTapped() ? CardPanel.TAPPED_ANGLE : 0; try { - log.info("loading image..."); + log.info(gameCard.getCardNumber() + " " + gameCard.getName() + " " + gameCard.getExpansionSetCode()); BufferedImage srcImage = ImageIO.read(CardPanel.class.getClassLoader().getResourceAsStream("Mountain.40.full.jpg")); - srcImage = null; - log.info("done, image="+srcImage); if (srcImage != null) { //setImage(srcImage, ImageUtil.getBlurredImage(srcImage, 3, 1.0f)); hasImage = true; @@ -153,7 +148,7 @@ public class CardPanel extends MagePermanent { if (hasImage) { titleText.setText(""); } else { - titleText.setText(card.getName() + card.getId()); + titleText.setText(card.getName()); } } @@ -268,6 +263,9 @@ public class CardPanel extends MagePermanent { }*/ + //for debugging + // REMOVEME + /* Point component = getLocation(); int cx = getCardX() + component.x; @@ -275,10 +273,9 @@ public class CardPanel extends MagePermanent { int cw = getCardWidth(); int ch = getCardHeight(); - System.out.println("x="+component.x); - g2d.setColor(Color.white); g2d.drawRect(getCardX() - component.x, getCardY() - component.y, cw, ch); + */ } protected void paintChildren (Graphics g) { @@ -488,7 +485,6 @@ public class CardPanel extends MagePermanent { int cw = getCardWidth(); int ch = getCardHeight(); if (isTapped()) { - //log.info("tapped"); cy = ch - cw + cx /*+ attachedDy*attachedCount*/; ch = cw; cw = getCardHeight(); @@ -511,4 +507,9 @@ public class CardPanel extends MagePermanent { return this.gameCard; } + @Override + public Image getImage() { + return this.imagePanel.getSrcImage(); + } + } diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ScaledImagePanel.java b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ScaledImagePanel.java index 9045711064..7f7656c7e3 100644 --- a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ScaledImagePanel.java +++ b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ScaledImagePanel.java @@ -172,6 +172,10 @@ public class ScaledImagePanel extends JPanel { if (info.srcWidth / 2 < info.targetWidth || info.srcHeight / 2 < info.targetHeight) return srcImage; return srcImageBlurred; } + + public Image getSrcImage() { + return srcImage; + } static private class ScalingInfo { public int targetWidth; diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/CardPluginImpl.java b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/CardPluginImpl.java index fc8f8e1633..1fc33d21f2 100644 --- a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/CardPluginImpl.java +++ b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/CardPluginImpl.java @@ -1,19 +1,21 @@ package org.mage.plugins.card; +import java.awt.Color; import java.awt.Rectangle; -import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.UUID; +import javax.swing.BorderFactory; import javax.swing.JComponent; +import javax.swing.JLayeredPane; import javax.swing.JScrollPane; import mage.cards.CardDimensions; import mage.cards.MagePermanent; -import mage.cards.interfaces.ActionCallback; +import mage.cards.action.ActionCallback; import mage.interfaces.plugin.CardPlugin; import mage.utils.CardUtil; import mage.view.PermanentView; @@ -66,7 +68,7 @@ public class CardPluginImpl implements CardPlugin { @Override public MagePermanent getMagePermanent(PermanentView permanent, CardDimensions dimension, UUID gameId, ActionCallback callback) { //log.debug("Card plugin: building mage permanent [w="+dimension.frameWidth+",h="+dimension.frameHeight+"]"); - CardPanel cardPanel = new CardPanel(permanent, false, callback); + CardPanel cardPanel = new CardPanel(permanent, true, callback); cardPanel.setShowCastingCost(true); cardPanel.setCardBounds(0, 0, dimension.frameWidth, dimension.frameHeight); //cardPanel.setBorder(BorderFactory.createLineBorder(Color.red)); @@ -78,12 +80,18 @@ public class CardPluginImpl implements CardPlugin { if (ui == null) throw new RuntimeException("Error: no components"); JComponent component = ui.get("jScrollPane"); + JComponent component2 = ui.get("battlefieldPanel"); if (component == null) throw new RuntimeException("Error: jScrollPane is missing"); + if (component2 == null) + throw new RuntimeException("Error: battlefieldPanel is missing"); if (!(component instanceof JScrollPane)) throw new RuntimeException("Error: jScrollPane has wrong type."); + if (!(component instanceof JScrollPane)) + throw new RuntimeException("Error: battlefieldPanel is missing"); JScrollPane jScrollPane = (JScrollPane)component; + JLayeredPane battlefieldPanel = (JLayeredPane)component2; Row allLands = new Row(); @@ -203,11 +211,12 @@ public class CardPluginImpl implements CardPlugin { for (int panelIndex = 0, panelCount = stack.size(); panelIndex < panelCount; panelIndex++) { MagePermanent panel = stack.get(panelIndex); int stackPosition = panelCount - panelIndex - 1; - //setComponentZOrder((Component)panel, panelIndex); + ///setComponentZOrder((Component)panel, panelIndex); int panelX = x + (stackPosition * stackSpacingX); int panelY = y + (stackPosition * stackSpacingY); - ///panel.setLocation(panelX, panelY); - panel.setCardBounds(panelX, panelY, cardWidth, cardHeight); + //panel.setLocation(panelX, panelY); + battlefieldPanel.moveToBack(panel); + panel.setCardBounds(panelX + 100, panelY+70, cardWidth, cardHeight); } rowBottom = Math.max(rowBottom, y + stack.getHeight()); x += stack.getWidth(); diff --git a/Mage.Server/config/init.txt b/Mage.Server/config/init.txt index e21f4e2791..a3caa6e02c 100644 --- a/Mage.Server/config/init.txt +++ b/Mage.Server/config/init.txt @@ -7,5 +7,5 @@ # # hand:player:Fireball:2 -battlefield:player:Mountain:6 +battlefield:player:Mountain:5 battlefield:computer:Brindle Boar:2 diff --git a/pom.xml b/pom.xml index bd1a9a894d..a9869b1dbe 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,11 @@ <id>mage.googlecode.com</id> <url>http://magic--another-game-engine.googlecode.com/svn/trunk/repository</url> </repository> + <repository> + <id>java-image-scaling</id> + <name>Java Image Scaling Repository Released</name> + <url>svn:https://java-image-scaling.googlecode.com/svn/repo/released</url> + </repository> </repositories> <properties>