mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
[card.plugin] now cards displayed on hand and stack (some stuff still needs to be updated). PLEASE DO REBUILD PLUGIN IF U USE mage-card-plugins.jar.
This commit is contained in:
parent
06b7e63843
commit
63d8231928
13 changed files with 168 additions and 62 deletions
|
|
@ -479,4 +479,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
||||||
public Image getImage() {
|
public Image getImage() {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PermanentView getOriginalPermanent() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,23 @@
|
||||||
|
|
||||||
package mage.client.cards;
|
package mage.client.cards;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
|
||||||
|
import mage.cards.CardDimensions;
|
||||||
|
import mage.cards.MageCard;
|
||||||
|
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.Config;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
import mage.view.CardsView;
|
import mage.view.CardsView;
|
||||||
|
|
@ -52,7 +61,8 @@ import mage.view.CardsView;
|
||||||
*/
|
*/
|
||||||
public class Cards extends javax.swing.JPanel {
|
public class Cards extends javax.swing.JPanel {
|
||||||
|
|
||||||
private Map<UUID, Card> cards = new HashMap<UUID, Card>();
|
private Map<UUID, MageCard> cards = new HashMap<UUID, MageCard>();
|
||||||
|
private boolean mouseHandlingEnabled = false;
|
||||||
|
|
||||||
/** Creates new form Cards */
|
/** Creates new form Cards */
|
||||||
public Cards() {
|
public Cards() {
|
||||||
|
|
@ -61,21 +71,22 @@ public class Cards extends javax.swing.JPanel {
|
||||||
jScrollPane1.setOpaque(false);
|
jScrollPane1.setOpaque(false);
|
||||||
jScrollPane1.getViewport().setOpaque(false);
|
jScrollPane1.getViewport().setOpaque(false);
|
||||||
cardArea.setOpaque(false);
|
cardArea.setOpaque(false);
|
||||||
|
if (Plugins.getInstance().isCardPluginLoaded()) {
|
||||||
|
cardArea.setLayout(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId) {
|
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId) {
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (CardView card: cardsView.values()) {
|
for (CardView card: cardsView.values()) {
|
||||||
if (!cards.containsKey(card.getId())) {
|
if (!cards.containsKey(card.getId())) {
|
||||||
Card cardImg = new Card(card, bigCard, Config.dimensions, gameId);
|
addCard(card, bigCard, gameId);
|
||||||
cards.put(card.getId(), cardImg);
|
|
||||||
cardArea.add(cardImg);
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
cards.get(card.getId()).update(card);
|
cards.get(card.getId()).update(card);
|
||||||
}
|
}
|
||||||
for (Iterator<Entry<UUID, Card>> i = cards.entrySet().iterator(); i.hasNext();) {
|
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) {
|
||||||
Entry<UUID, Card> entry = i.next();
|
Entry<UUID, MageCard> entry = i.next();
|
||||||
if (!cardsView.containsKey(entry.getKey())) {
|
if (!cardsView.containsKey(entry.getKey())) {
|
||||||
removeCard(entry.getKey());
|
removeCard(entry.getKey());
|
||||||
i.remove();
|
i.remove();
|
||||||
|
|
@ -83,24 +94,64 @@ public class Cards extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mouseHandlingEnabled) {
|
||||||
|
synchronized (this) {
|
||||||
|
if (!mouseHandlingEnabled) {
|
||||||
|
mouseHandlingEnabled = true;
|
||||||
|
//cardArea.addMouseListener(new MageMouseAdapter(this, gameId));
|
||||||
|
//cardArea.addMouseMotionListener(new MageMouseMotionAdapter(this, bigCard));
|
||||||
|
jScrollPane1.addMouseListener(new MageMouseAdapter(cardArea, gameId));
|
||||||
|
jScrollPane1.addMouseMotionListener(new MageMouseMotionAdapter(cardArea, bigCard));
|
||||||
|
//addMouseListener(new MageMouseAdapter(this, gameId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cardArea.setPreferredSize(new Dimension(cards.size() * Config.dimensions.frameWidth, Config.dimensions.frameHeight));
|
cardArea.setPreferredSize(new Dimension(cards.size() * Config.dimensions.frameWidth, Config.dimensions.frameHeight));
|
||||||
cardArea.revalidate();
|
cardArea.revalidate();
|
||||||
cardArea.repaint();
|
cardArea.repaint();
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
this.repaint();
|
this.repaint();
|
||||||
|
if (changed) {
|
||||||
|
layoutCards(Config.dimensions);
|
||||||
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
|
||||||
|
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, Config.dimensions, gameId);
|
||||||
|
cards.put(card.getId(), cardImg);
|
||||||
|
cardArea.add(cardImg);
|
||||||
|
/*if (Plugins.getInstance().isCardPluginLoaded()) {
|
||||||
|
cardImg.setBorder(BorderFactory.createLineBorder(Color.red));
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
private void removeCard(UUID cardId) {
|
private void removeCard(UUID cardId) {
|
||||||
for (Component comp: cardArea.getComponents()) {
|
for (Component comp: cardArea.getComponents()) {
|
||||||
if (comp instanceof Card) {
|
if (comp instanceof Card) {
|
||||||
if (((Card)comp).getCardId().equals(cardId)) {
|
if (((Card)comp).getCardId().equals(cardId)) {
|
||||||
cardArea.remove(comp);
|
cardArea.remove(comp);
|
||||||
}
|
}
|
||||||
|
} else if (comp instanceof MageCard) {
|
||||||
|
if (((MageCard)comp).getOriginal().equals(cardId)) {
|
||||||
|
cardArea.remove(comp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void layoutCards(CardDimensions dimension) {
|
||||||
|
if (Plugins.getInstance().isCardPluginLoaded()) {
|
||||||
|
int dx = 0;
|
||||||
|
for (MageCard card: cards.values()) {
|
||||||
|
card.setLocation(dx, 0);
|
||||||
|
card.setCardBounds(dx, 0, dimension.frameWidth, dimension.frameHeight);
|
||||||
|
dx += dimension.frameWidth + 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/** This method is called from within the constructor to
|
||||||
* initialize the form.
|
* initialize the form.
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane implements Compon
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPermanent(PermanentView permanent) {
|
private void addPermanent(PermanentView permanent) {
|
||||||
MagePermanent perm = Plugins.getInstance().getMagePermanent(permanent, bigCard, Config.dimensions, gameId);;
|
MagePermanent perm = Plugins.getInstance().getMagePermanent(permanent, bigCard, Config.dimensions, gameId);
|
||||||
perm.addComponentListener(this);
|
perm.addComponentListener(this);
|
||||||
if (!Plugins.getInstance().isCardPluginLoaded()) {
|
if (!Plugins.getInstance().isCardPluginLoaded()) {
|
||||||
perm.setBounds(findEmptySpace(new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight)));
|
perm.setBounds(findEmptySpace(new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight)));
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,10 @@ import javax.swing.JComponent;
|
||||||
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardDimensions;
|
import mage.cards.CardDimensions;
|
||||||
|
import mage.cards.MageCard;
|
||||||
import mage.cards.MagePermanent;
|
import mage.cards.MagePermanent;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
|
import mage.view.CardView;
|
||||||
import mage.view.PermanentView;
|
import mage.view.PermanentView;
|
||||||
|
|
||||||
public interface MagePlugins {
|
public interface MagePlugins {
|
||||||
|
|
@ -19,6 +21,7 @@ public interface MagePlugins {
|
||||||
void updateGamePanel(Map<String, JComponent> ui);
|
void updateGamePanel(Map<String, JComponent> ui);
|
||||||
JComponent updateTablePanel(Map<String, JComponent> ui);
|
JComponent updateTablePanel(Map<String, JComponent> ui);
|
||||||
MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, CardDimensions dimension, UUID gameId);
|
MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, CardDimensions dimension, UUID gameId);
|
||||||
|
MageCard getMageCard(CardView card, BigCard bigCard, CardDimensions dimension, UUID gameId);
|
||||||
boolean isThemePluginLoaded();
|
boolean isThemePluginLoaded();
|
||||||
boolean isCardPluginLoaded();
|
boolean isCardPluginLoaded();
|
||||||
boolean isCounterPluginLoaded();
|
boolean isCounterPluginLoaded();
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,14 @@
|
||||||
package mage.client.plugins.adapters;
|
package mage.client.plugins.adapters;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Point;
|
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.swing.Popup;
|
import mage.cards.MageCard;
|
||||||
import javax.swing.PopupFactory;
|
|
||||||
|
|
||||||
import mage.cards.MagePermanent;
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.game.PlayAreaPanel;
|
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.Config;
|
|
||||||
import mage.client.util.DefaultActionCallback;
|
import mage.client.util.DefaultActionCallback;
|
||||||
import mage.client.util.gui.ArrowBuilder;
|
|
||||||
|
|
||||||
public class MageMouseAdapter extends MouseAdapter {
|
public class MageMouseAdapter extends MouseAdapter {
|
||||||
|
|
||||||
|
|
@ -38,8 +29,8 @@ public class MageMouseAdapter extends MouseAdapter {
|
||||||
int count = e.getClickCount();
|
int count = e.getClickCount();
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
Object o = parent.getComponentAt(e.getPoint());
|
Object o = parent.getComponentAt(e.getPoint());
|
||||||
if (o instanceof MagePermanent) {
|
if (o instanceof MageCard) {
|
||||||
MagePermanent selectedCard = (MagePermanent) o;
|
MageCard selectedCard = (MageCard) o;
|
||||||
// TODO: uncomment when attached cards works in plugin
|
// TODO: uncomment when attached cards works in plugin
|
||||||
/*
|
/*
|
||||||
* int x = e.getX() - selectedCard.getX(); int y = e.getY()
|
* int x = e.getX() - selectedCard.getX(); int y = e.getY()
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseMotionAdapter;
|
import java.awt.event.MouseMotionAdapter;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import mage.cards.MageCard;
|
||||||
import mage.cards.MagePermanent;
|
import mage.cards.MagePermanent;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
|
|
@ -29,8 +30,8 @@ public class MageMouseMotionAdapter extends MouseMotionAdapter {
|
||||||
if (!Plugins.getInstance().isCardPluginLoaded()) {return;}
|
if (!Plugins.getInstance().isCardPluginLoaded()) {return;}
|
||||||
if (bigCard == null) {return;}
|
if (bigCard == null) {return;}
|
||||||
Object o = parent.getComponentAt(e.getPoint());
|
Object o = parent.getComponentAt(e.getPoint());
|
||||||
if (o instanceof MagePermanent) {
|
if (o instanceof MageCard) {
|
||||||
MagePermanent card = (MagePermanent) o;
|
MageCard card = (MageCard) o;
|
||||||
if (card.getOriginal().getId() != bigCard.getCardId()) {
|
if (card.getOriginal().getId() != bigCard.getCardId()) {
|
||||||
synchronized (MageMouseAdapter.class) {
|
synchronized (MageMouseAdapter.class) {
|
||||||
if (card.getOriginal().getId() != bigCard.getCardId()) {
|
if (card.getOriginal().getId() != bigCard.getCardId()) {
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,12 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
import mage.cards.Card;
|
|
||||||
import mage.cards.CardDimensions;
|
import mage.cards.CardDimensions;
|
||||||
|
import mage.cards.MageCard;
|
||||||
import mage.cards.MagePermanent;
|
import mage.cards.MagePermanent;
|
||||||
import mage.cards.action.impl.EmptyCallback;
|
import mage.cards.action.impl.EmptyCallback;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
|
import mage.client.cards.Card;
|
||||||
import mage.client.cards.Permanent;
|
import mage.client.cards.Permanent;
|
||||||
import mage.client.plugins.MagePlugins;
|
import mage.client.plugins.MagePlugins;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
|
|
@ -25,10 +26,10 @@ import mage.interfaces.plugin.CardPlugin;
|
||||||
import mage.interfaces.plugin.CounterPlugin;
|
import mage.interfaces.plugin.CounterPlugin;
|
||||||
import mage.interfaces.plugin.ThemePlugin;
|
import mage.interfaces.plugin.ThemePlugin;
|
||||||
import mage.util.Logging;
|
import mage.util.Logging;
|
||||||
|
import mage.view.CardView;
|
||||||
import mage.view.PermanentView;
|
import mage.view.PermanentView;
|
||||||
import net.xeoh.plugins.base.PluginManager;
|
import net.xeoh.plugins.base.PluginManager;
|
||||||
import net.xeoh.plugins.base.impl.PluginManagerFactory;
|
import net.xeoh.plugins.base.impl.PluginManagerFactory;
|
||||||
import net.xeoh.plugins.base.util.PluginManagerUtil;
|
|
||||||
|
|
||||||
|
|
||||||
public class Plugins implements MagePlugins {
|
public class Plugins implements MagePlugins {
|
||||||
|
|
@ -73,7 +74,7 @@ public class Plugins implements MagePlugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MagePermanent getMagePermanent(final PermanentView card, BigCard bigCard, CardDimensions dimension, final UUID gameId) {
|
public MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
||||||
if (cardPlugin != null) {
|
if (cardPlugin != null) {
|
||||||
return cardPlugin.getMagePermanent(card, dimension, gameId, emptyCallback);
|
return cardPlugin.getMagePermanent(card, dimension, gameId, emptyCallback);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -81,6 +82,15 @@ public class Plugins implements MagePlugins {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MageCard getMageCard(CardView card, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
||||||
|
if (cardPlugin != null) {
|
||||||
|
return cardPlugin.getMageCard(card, dimension, gameId, emptyCallback);
|
||||||
|
} else {
|
||||||
|
return new Card(card, bigCard, Config.dimensions, gameId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCardPluginLoaded() {
|
public boolean isCardPluginLoaded() {
|
||||||
return this.cardPlugin != null;
|
return this.cardPlugin != null;
|
||||||
|
|
@ -92,7 +102,7 @@ public class Plugins implements MagePlugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void downloadImage(Set<Card> allCards) {
|
public void downloadImage(Set<mage.cards.Card> allCards) {
|
||||||
if (this.cardPlugin != null) this.cardPlugin.downloadImages(allCards);
|
if (this.cardPlugin != null) this.cardPlugin.downloadImages(allCards);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
21
Mage.Common/src/mage/cards/MageCard.java
Normal file
21
Mage.Common/src/mage/cards/MageCard.java
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
package mage.cards;
|
||||||
|
|
||||||
|
import java.awt.Image;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import mage.view.CardView;
|
||||||
|
import mage.view.PermanentView;
|
||||||
|
|
||||||
|
public abstract class MageCard extends JPanel {
|
||||||
|
private static final long serialVersionUID = 6089945326434301879L;
|
||||||
|
|
||||||
|
abstract public void onBeginAnimation();
|
||||||
|
abstract public void onEndAnimation();
|
||||||
|
abstract public boolean isTapped();
|
||||||
|
abstract public void setAlpha(float transparency);
|
||||||
|
abstract public CardView getOriginal();
|
||||||
|
abstract public void setCardBounds(int x, int y, int width, int height);
|
||||||
|
abstract public void update(CardView card);
|
||||||
|
abstract public Image getImage();
|
||||||
|
}
|
||||||
|
|
@ -1,22 +1,12 @@
|
||||||
package mage.cards;
|
package mage.cards;
|
||||||
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
import mage.view.PermanentView;
|
import mage.view.PermanentView;
|
||||||
|
|
||||||
public abstract class MagePermanent extends JPanel {
|
public abstract class MagePermanent extends MageCard {
|
||||||
private static final long serialVersionUID = -3469258620601702171L;
|
private static final long serialVersionUID = -3469258620601702171L;
|
||||||
abstract public List<MagePermanent> getLinks();
|
abstract public List<MagePermanent> getLinks();
|
||||||
|
|
||||||
abstract public void onBeginAnimation();
|
|
||||||
abstract public void onEndAnimation();
|
|
||||||
abstract public boolean isTapped();
|
|
||||||
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 void update(PermanentView card);
|
||||||
abstract public Image getImage();
|
abstract public PermanentView getOriginalPermanent();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,17 +11,21 @@ import mage.cards.Card;
|
||||||
import mage.cards.CardDimensions;
|
import mage.cards.CardDimensions;
|
||||||
import mage.cards.MagePermanent;
|
import mage.cards.MagePermanent;
|
||||||
import mage.cards.action.ActionCallback;
|
import mage.cards.action.ActionCallback;
|
||||||
|
import mage.view.CardView;
|
||||||
import mage.view.PermanentView;
|
import mage.view.PermanentView;
|
||||||
import net.xeoh.plugins.base.Plugin;
|
import net.xeoh.plugins.base.Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for card plugins
|
* Interface for card plugins
|
||||||
*
|
*
|
||||||
* @version 0.1 31.10.2010
|
* @version 0.3 21.11.2010 #getMageCard
|
||||||
|
* @version 0.2 07.11.2010 #downloadImages
|
||||||
|
* @version 0.1 31.10.2010 #getMagePermanent, #sortPermanents
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
*/
|
*/
|
||||||
public interface CardPlugin extends Plugin {
|
public interface CardPlugin extends Plugin {
|
||||||
MagePermanent getMagePermanent(PermanentView permanent, CardDimensions dimension, UUID gameId, ActionCallback callback);
|
MagePermanent getMagePermanent(PermanentView permanent, CardDimensions dimension, UUID gameId, ActionCallback callback);
|
||||||
|
MagePermanent getMageCard(CardView permanent, CardDimensions dimension, UUID gameId, ActionCallback callback);
|
||||||
void sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> cards);
|
void sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> cards);
|
||||||
void downloadImages(Set<Card> allCards);
|
void downloadImages(Set<Card> allCards);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -110,12 +110,12 @@ abstract public class Animation {
|
||||||
|
|
||||||
protected void update (float percentage) {
|
protected void update (float percentage) {
|
||||||
panel.tappedAngle = CardPanel.TAPPED_ANGLE * percentage;
|
panel.tappedAngle = CardPanel.TAPPED_ANGLE * percentage;
|
||||||
if (!panel.gameCard.isTapped()) panel.tappedAngle = CardPanel.TAPPED_ANGLE - panel.tappedAngle;
|
if (!panel.isTapped()) panel.tappedAngle = CardPanel.TAPPED_ANGLE - panel.tappedAngle;
|
||||||
panel.repaint();
|
panel.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void end () {
|
protected void end () {
|
||||||
panel.tappedAngle = panel.gameCard.isTapped() ? CardPanel.TAPPED_ANGLE : 0;
|
panel.tappedAngle = panel.isTapped() ? CardPanel.TAPPED_ANGLE : 0;
|
||||||
parent.onEndAnimation();
|
parent.onEndAnimation();
|
||||||
parent.repaint();
|
parent.repaint();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,6 @@ import org.mage.card.arcane.ScaledImagePanel.MultipassType;
|
||||||
import org.mage.card.arcane.ScaledImagePanel.ScalingType;
|
import org.mage.card.arcane.ScaledImagePanel.ScalingType;
|
||||||
import org.mage.plugins.card.images.ImageCache;
|
import org.mage.plugins.card.images.ImageCache;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked","rawtypes"})
|
@SuppressWarnings({"unchecked","rawtypes"})
|
||||||
public class CardPanel extends MagePermanent implements MouseListener {
|
public class CardPanel extends MagePermanent implements MouseListener {
|
||||||
|
|
@ -62,7 +60,8 @@ public class CardPanel extends MagePermanent implements MouseListener {
|
||||||
static private final float rotCenterToTopCorner = 1.0295630140987000315797369464196f;
|
static private final float rotCenterToTopCorner = 1.0295630140987000315797369464196f;
|
||||||
static private final float rotCenterToBottomCorner = 0.7071067811865475244008443621048f;
|
static private final float rotCenterToBottomCorner = 0.7071067811865475244008443621048f;
|
||||||
|
|
||||||
public PermanentView gameCard;
|
public CardView gameCard;
|
||||||
|
public PermanentView gamePermanent;
|
||||||
public CardPanel attachedToPanel;
|
public CardPanel attachedToPanel;
|
||||||
public List<CardPanel> attachedPanels = new ArrayList();
|
public List<CardPanel> attachedPanels = new ArrayList();
|
||||||
public double tappedAngle = 0;
|
public double tappedAngle = 0;
|
||||||
|
|
@ -87,9 +86,16 @@ public class CardPanel extends MagePermanent implements MouseListener {
|
||||||
protected boolean popupShowing;
|
protected boolean popupShowing;
|
||||||
protected TextPopup popupText = new TextPopup();
|
protected TextPopup popupText = new TextPopup();
|
||||||
|
|
||||||
public CardPanel (PermanentView newGameCard, boolean loadImage, ActionCallback callback) {
|
private boolean isPermanent;
|
||||||
|
|
||||||
|
public CardPanel(CardView newGameCard, boolean loadImage, ActionCallback callback) {
|
||||||
this.gameCard = newGameCard;
|
this.gameCard = newGameCard;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
|
this.isPermanent = this.gameCard instanceof PermanentView;
|
||||||
|
|
||||||
|
if (isPermanent) {
|
||||||
|
this.gamePermanent = (PermanentView) this.gameCard;
|
||||||
|
}
|
||||||
|
|
||||||
//for container debug (don't remove)
|
//for container debug (don't remove)
|
||||||
//setBorder(BorderFactory.createLineBorder(Color.green));
|
//setBorder(BorderFactory.createLineBorder(Color.green));
|
||||||
|
|
@ -111,7 +117,7 @@ public class CardPanel extends MagePermanent implements MouseListener {
|
||||||
if (CardUtil.isCreature(gameCard)) {
|
if (CardUtil.isCreature(gameCard)) {
|
||||||
ptText.setText(gameCard.getPower() + "/" + gameCard.getToughness());
|
ptText.setText(gameCard.getPower() + "/" + gameCard.getToughness());
|
||||||
} else if (CardUtil.isPlaneswalker(gameCard)) {
|
} else if (CardUtil.isPlaneswalker(gameCard)) {
|
||||||
ptText.setText(gameCard.getOriginal().getLoyalty());
|
ptText.setText(gameCard.getLoyalty());
|
||||||
}
|
}
|
||||||
ptText.setFont(getFont().deriveFont(Font.BOLD, 13f));
|
ptText.setFont(getFont().deriveFont(Font.BOLD, 13f));
|
||||||
ptText.setForeground(Color.white);
|
ptText.setForeground(Color.white);
|
||||||
|
|
@ -146,7 +152,7 @@ public class CardPanel extends MagePermanent implements MouseListener {
|
||||||
Util.threadPool.submit(new Runnable() {
|
Util.threadPool.submit(new Runnable() {
|
||||||
public void run () {
|
public void run () {
|
||||||
try {
|
try {
|
||||||
tappedAngle = gameCard.isTapped() ? CardPanel.TAPPED_ANGLE : 0;
|
tappedAngle = isTapped() ? CardPanel.TAPPED_ANGLE : 0;
|
||||||
BufferedImage srcImage = ImageCache.getImageOriginal(gameCard);
|
BufferedImage srcImage = ImageCache.getImageOriginal(gameCard);
|
||||||
srcImage = ImageCache.getNormalSizeImage(srcImage);
|
srcImage = ImageCache.getNormalSizeImage(srcImage);
|
||||||
if (srcImage != null) {
|
if (srcImage != null) {
|
||||||
|
|
@ -165,7 +171,7 @@ public class CardPanel extends MagePermanent implements MouseListener {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setText(PermanentView card) {
|
private void setText(CardView card) {
|
||||||
if (hasImage) {
|
if (hasImage) {
|
||||||
titleText.setText("");
|
titleText.setText("");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -400,7 +406,7 @@ public class CardPanel extends MagePermanent implements MouseListener {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PermanentView getCard() {
|
public CardView getCard() {
|
||||||
return this.gameCard;
|
return this.gameCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -426,13 +432,13 @@ public class CardPanel extends MagePermanent implements MouseListener {
|
||||||
Util.threadPool.submit(new Runnable() {
|
Util.threadPool.submit(new Runnable() {
|
||||||
public void run () {
|
public void run () {
|
||||||
//TODO: BufferedImage srcImage = ImageCache.getImageOriginal(gameCard);
|
//TODO: BufferedImage srcImage = ImageCache.getImageOriginal(gameCard);
|
||||||
BufferedImage srcImage = null;
|
//BufferedImage srcImage = null;
|
||||||
tappedAngle = gameCard.isTapped() ? CardPanel.TAPPED_ANGLE : 0;
|
//tappedAngle = isTapped() ? CardPanel.TAPPED_ANGLE : 0;
|
||||||
if (srcImage != null) {
|
/*if (srcImage != null) {
|
||||||
hasImage = true;
|
hasImage = true;
|
||||||
setText(gameCard);
|
setText(gameCard);
|
||||||
setImage(srcImage, srcImage);
|
setImage(srcImage, srcImage);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -450,7 +456,10 @@ public class CardPanel extends MagePermanent implements MouseListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTapped() {
|
public boolean isTapped() {
|
||||||
return gameCard.isTapped();
|
if (isPermanent) {
|
||||||
|
return ((PermanentView)gameCard).isTapped();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -462,9 +471,11 @@ public class CardPanel extends MagePermanent implements MouseListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(PermanentView card) {
|
public void update(CardView card) {
|
||||||
if (this.gameCard.isTapped() != card.isTapped()) {
|
if (isPermanent) {
|
||||||
Animation.tapCardToggle(this, this);
|
if (isTapped() != ((PermanentView)card).isTapped()) {
|
||||||
|
Animation.tapCardToggle(this, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (CardUtil.isCreature(card) && CardUtil.isPlaneswalker(card)) {
|
if (CardUtil.isCreature(card) && CardUtil.isPlaneswalker(card)) {
|
||||||
ptText.setText(card.getPower() + "/" + card.getToughness() + " (" + card.getLoyalty() + ")");
|
ptText.setText(card.getPower() + "/" + card.getToughness() + " (" + card.getLoyalty() + ")");
|
||||||
|
|
@ -533,7 +544,7 @@ public class CardPanel extends MagePermanent implements MouseListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermanentView getOriginal() {
|
public CardView getOriginal() {
|
||||||
return this.gameCard;
|
return this.gameCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -632,4 +643,14 @@ public class CardPanel extends MagePermanent implements MouseListener {
|
||||||
// sb.append("\n").append(card.getId());
|
// sb.append("\n").append(card.getId());
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(PermanentView card) {
|
||||||
|
update((CardView)card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PermanentView getOriginalPermanent() {
|
||||||
|
throw new IllegalStateException("Is not permanent.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import mage.cards.MagePermanent;
|
||||||
import mage.cards.action.ActionCallback;
|
import mage.cards.action.ActionCallback;
|
||||||
import mage.interfaces.plugin.CardPlugin;
|
import mage.interfaces.plugin.CardPlugin;
|
||||||
import mage.utils.CardUtil;
|
import mage.utils.CardUtil;
|
||||||
|
import mage.view.CardView;
|
||||||
import mage.view.PermanentView;
|
import mage.view.PermanentView;
|
||||||
import net.xeoh.plugins.base.annotations.PluginImplementation;
|
import net.xeoh.plugins.base.annotations.PluginImplementation;
|
||||||
import net.xeoh.plugins.base.annotations.events.Init;
|
import net.xeoh.plugins.base.annotations.events.Init;
|
||||||
|
|
@ -32,7 +33,9 @@ import org.mage.plugins.card.images.DownloadPictures;
|
||||||
/**
|
/**
|
||||||
* {@link CardPlugin} implementation.
|
* {@link CardPlugin} implementation.
|
||||||
*
|
*
|
||||||
* @version 0.1 01.11.2010
|
* @version 0.3 07.11.2010 Mage cards.
|
||||||
|
* @version 0.2 07.11.2010 Downloading images.
|
||||||
|
* @version 0.1 01.11.2010 Mage permanents. Sorting card layout.
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
*/
|
*/
|
||||||
@PluginImplementation
|
@PluginImplementation
|
||||||
|
|
@ -69,16 +72,22 @@ public class CardPluginImpl implements CardPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[Card plugin, version 0.2]";
|
return "[Card plugin, version 0.3]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MagePermanent getMagePermanent(PermanentView permanent, CardDimensions dimension, UUID gameId, ActionCallback callback) {
|
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, true, callback);
|
CardPanel cardPanel = new CardPanel(permanent, true, callback);
|
||||||
cardPanel.setShowCastingCost(true);
|
cardPanel.setShowCastingCost(true);
|
||||||
cardPanel.setCardBounds(0, 0, dimension.frameWidth, dimension.frameHeight);
|
cardPanel.setCardBounds(0, 0, dimension.frameWidth, dimension.frameHeight);
|
||||||
//cardPanel.setBorder(BorderFactory.createLineBorder(Color.red));
|
return cardPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MagePermanent getMageCard(CardView permanent, CardDimensions dimension, UUID gameId, ActionCallback callback) {
|
||||||
|
CardPanel cardPanel = new CardPanel(permanent, true, callback);
|
||||||
|
cardPanel.setShowCastingCost(true);
|
||||||
|
cardPanel.setCardBounds(0, 0, dimension.frameWidth, dimension.frameHeight);
|
||||||
return cardPanel;
|
return cardPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue