forked from External/mage
* Improved handling of enlarged images. Added mode to show other side of flip and transform cards. Added icon for copied cards and possibility to show enlarged original or copied card.
This commit is contained in:
parent
0babf49392
commit
59d907c981
24 changed files with 490 additions and 233 deletions
|
|
@ -47,6 +47,7 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
import static mage.constants.Constants.*;
|
||||
import mage.constants.EnlargeMode;
|
||||
|
||||
/**
|
||||
* Class for displaying big image of the card
|
||||
|
|
@ -65,6 +66,7 @@ public class BigCard extends JComponent {
|
|||
protected Thread foilThread;
|
||||
protected float hue = 0.005f;
|
||||
protected float dh = 0.005f;
|
||||
protected EnlargeMode enlargeMode;
|
||||
|
||||
public BigCard() {
|
||||
initComponents();
|
||||
|
|
@ -87,19 +89,20 @@ public class BigCard extends JComponent {
|
|||
|
||||
}
|
||||
|
||||
public void setCard(UUID cardId, Image image, List<String> strings, boolean foil) {
|
||||
if (this.cardId == null || !this.cardId.equals(cardId)) {
|
||||
public void setCard(UUID cardId, EnlargeMode enlargeMode, Image image, List<String> strings) {
|
||||
if (this.cardId == null || !enlargeMode.equals(this.enlargeMode) || !this.cardId.equals(cardId)) {
|
||||
if (this.panel != null) {
|
||||
remove(this.panel);
|
||||
}
|
||||
this.cardId = cardId;
|
||||
this.enlargeMode = enlargeMode;
|
||||
bigImage = image;
|
||||
synchronized (this) {
|
||||
source = null;
|
||||
hue = 0.000f;
|
||||
}
|
||||
drawText(strings);
|
||||
setFoil(foil);
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -143,10 +146,6 @@ public class BigCard extends JComponent {
|
|||
this.scrollPane.setVisible(true);
|
||||
}
|
||||
|
||||
public void setFoil(boolean foil) {
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void addJXPanel(UUID cardId, JXPanel jxPanel) {
|
||||
bigImage = null;
|
||||
synchronized (this) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.1" encoding="UTF-8" ?>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
|
|
|
|||
|
|
@ -34,36 +34,64 @@
|
|||
|
||||
package mage.client.cards;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import java.awt.Color;
|
||||
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;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.Popup;
|
||||
import javax.swing.PopupFactory;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.Style;
|
||||
import javax.swing.text.StyleConstants;
|
||||
import javax.swing.text.StyleContext;
|
||||
import javax.swing.text.StyledDocument;
|
||||
import mage.cards.CardDimensions;
|
||||
import mage.cards.MagePermanent;
|
||||
import mage.cards.Sets;
|
||||
import mage.cards.TextPopup;
|
||||
import mage.cards.action.ActionCallback;
|
||||
import mage.client.MageFrame;
|
||||
import static mage.client.constants.Constants.CONTENT_MAX_XOFFSET;
|
||||
import static mage.client.constants.Constants.FRAME_MAX_HEIGHT;
|
||||
import static mage.client.constants.Constants.FRAME_MAX_WIDTH;
|
||||
import static mage.client.constants.Constants.NAME_FONT_MAX_SIZE;
|
||||
import static mage.client.constants.Constants.NAME_MAX_YOFFSET;
|
||||
import static mage.client.constants.Constants.POWBOX_TEXT_MAX_LEFT;
|
||||
import static mage.client.constants.Constants.POWBOX_TEXT_MAX_TOP;
|
||||
import static mage.client.constants.Constants.SYMBOL_MAX_XOFFSET;
|
||||
import static mage.client.constants.Constants.SYMBOL_MAX_YOFFSET;
|
||||
import static mage.client.constants.Constants.TYPE_MAX_YOFFSET;
|
||||
import mage.client.game.PlayAreaPanel;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.DefaultActionCallback;
|
||||
import mage.client.util.ImageHelper;
|
||||
import mage.client.util.gui.ArrowBuilder;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.EnlargeMode;
|
||||
import mage.remote.Session;
|
||||
import mage.cards.Sets;
|
||||
import mage.view.AbilityView;
|
||||
import mage.view.CardView;
|
||||
import mage.view.CounterView;
|
||||
import mage.view.PermanentView;
|
||||
import mage.view.StackAbilityView;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static mage.constants.Constants.*;
|
||||
import mage.view.CounterView;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -89,7 +117,14 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
protected BufferedImage small;
|
||||
protected String backgroundName;
|
||||
|
||||
/** Creates new form Card */
|
||||
/**
|
||||
* Creates new form Card
|
||||
*
|
||||
* @param card
|
||||
* @param bigCard
|
||||
* @param dimension
|
||||
* @param gameId
|
||||
*/
|
||||
public Card(CardView card, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
||||
this.dimension = dimension;
|
||||
initComponents();
|
||||
|
|
@ -120,10 +155,12 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
return card.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(PermanentView permanent) {
|
||||
this.update((CardView)permanent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(CardView card) {
|
||||
this.card = card;
|
||||
Graphics2D gImage = image.createGraphics();
|
||||
|
|
@ -141,8 +178,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
gImage.setColor(Color.BLACK);
|
||||
gImage.drawImage(background, 0, 0, this);
|
||||
|
||||
if (card.getManaCost().size() > 0)
|
||||
if (card.getManaCost().size() > 0) {
|
||||
ImageHelper.drawCosts(card.getManaCost(), gImage, FRAME_MAX_WIDTH - SYMBOL_MAX_XOFFSET, SYMBOL_MAX_YOFFSET, this);
|
||||
}
|
||||
|
||||
gSmall.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
gSmall.setColor(Color.BLACK);
|
||||
|
|
@ -157,8 +195,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
gImage.drawString(card.getLoyalty(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
|
||||
}
|
||||
|
||||
if (card.getCardTypes().size() > 0)
|
||||
if (card.getCardTypes().size() > 0) {
|
||||
gImage.drawString(cardType, CONTENT_MAX_XOFFSET, TYPE_MAX_YOFFSET);
|
||||
}
|
||||
|
||||
gImage.dispose();
|
||||
|
||||
|
|
@ -171,8 +210,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
gSmall.drawString(card.getLoyalty(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
|
||||
}
|
||||
|
||||
if (card.getCardTypes().size() > 0)
|
||||
if (card.getCardTypes().size() > 0) {
|
||||
gSmall.drawString(cardType, Config.dimensions.contentXOffset, Config.dimensions.typeYOffset);
|
||||
}
|
||||
drawText();
|
||||
|
||||
gSmall.dispose();
|
||||
|
|
@ -217,7 +257,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
protected String getBackgroundName() {
|
||||
private String getBackgroundName() {
|
||||
if (card instanceof StackAbilityView || card instanceof AbilityView) {
|
||||
return "effect";
|
||||
}
|
||||
|
|
@ -237,8 +277,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
StyledDocument doc = text.getStyledDocument();
|
||||
|
||||
try {
|
||||
for (String rule: getRules())
|
||||
for (String rule: getRules()) {
|
||||
doc.insertString(doc.getLength(), rule + "\n", doc.getStyle("small"));
|
||||
}
|
||||
} catch (BadLocationException e) {}
|
||||
|
||||
text.setCaretPosition(0);
|
||||
|
|
@ -246,7 +287,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
|
||||
protected List<String> getRules() {
|
||||
if (card.getCounters() != null) {
|
||||
List<String> rules = new ArrayList<String>(card.getRules());
|
||||
List<String> rules = new ArrayList<>(card.getRules());
|
||||
for (CounterView counter: card.getCounters()) {
|
||||
rules.add(counter.getCount() + " x " + counter.getName());
|
||||
}
|
||||
|
|
@ -333,7 +374,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
@Override
|
||||
public void mouseMoved(MouseEvent arg0) {
|
||||
this.bigCard.showTextComponent();
|
||||
this.bigCard.setCard(card.getId(), image, getRules(), false);
|
||||
this.bigCard.setCard(card.getId(), EnlargeMode.NORMAL, image, getRules());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -353,8 +394,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
@Override
|
||||
public void mouseEntered(MouseEvent arg0) {
|
||||
if (!popupShowing) {
|
||||
if (popup != null)
|
||||
if (popup != null) {
|
||||
popup.hide();
|
||||
}
|
||||
PopupFactory factory = PopupFactory.getSharedInstance();
|
||||
popup = factory.getPopup(this, popupText, (int) this.getLocationOnScreen().getX() + Config.dimensions.frameWidth, (int) this.getLocationOnScreen().getY() + 40);
|
||||
popup.show();
|
||||
|
|
@ -368,9 +410,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
List<UUID> targets = card.getTargets();
|
||||
if (targets != null) {
|
||||
for (UUID uuid : targets) {
|
||||
PlayAreaPanel p = MageFrame.getGame(gameId).getPlayers().get(uuid);
|
||||
if (p != null) {
|
||||
Point target = p.getLocationOnScreen();
|
||||
PlayAreaPanel playAreaPanel = MageFrame.getGame(gameId).getPlayers().get(uuid);
|
||||
if (playAreaPanel != null) {
|
||||
Point target = playAreaPanel.getLocationOnScreen();
|
||||
Point me = this.getLocationOnScreen();
|
||||
ArrowBuilder.getBuilder().addArrow(gameId, (int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() - 40, Color.red, ArrowBuilder.Type.TARGET);
|
||||
} else {
|
||||
|
|
@ -390,7 +432,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent arg0) {
|
||||
if(getMousePosition(true) != null) return;
|
||||
if(getMousePosition(true) != null) {
|
||||
return;
|
||||
}
|
||||
if (popup != null) {
|
||||
popup.hide();
|
||||
popupShowing = false;
|
||||
|
|
@ -408,8 +452,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
|
||||
@Override
|
||||
public void focusLost(FocusEvent arg0) {
|
||||
if (popup != null)
|
||||
if (popup != null) {
|
||||
popup.hide();
|
||||
}
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
|
|
@ -433,8 +478,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
if (popup != null)
|
||||
if (popup != null) {
|
||||
popup.hide();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -491,7 +537,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getAlpha() {return 0;}
|
||||
public float getAlpha() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleTransformed() {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ import mage.client.util.ImageHelper;
|
|||
import mage.client.util.Listener;
|
||||
import mage.client.util.gui.GuiDisplayUtil;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.EnlargeMode;
|
||||
import mage.view.CardView;
|
||||
import mage.view.CardsView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -380,7 +381,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
if (image != null && image instanceof BufferedImage) {
|
||||
// XXX: scaled to fit width
|
||||
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth());
|
||||
bigCard.setCard(card.getId(), image, new ArrayList<String>(), false);
|
||||
bigCard.setCard(card.getId(), EnlargeMode.NORMAL, image, new ArrayList<String>());
|
||||
} else {
|
||||
drawCardText(card);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ import mage.client.util.Config;
|
|||
import mage.client.util.GameManager;
|
||||
import mage.client.util.PhaseManager;
|
||||
import mage.client.util.gui.ArrowBuilder;
|
||||
import mage.constants.EnlargeMode;
|
||||
import mage.constants.PhaseStep;
|
||||
import static mage.constants.PhaseStep.BEGIN_COMBAT;
|
||||
import static mage.constants.PhaseStep.COMBAT_DAMAGE;
|
||||
|
|
@ -952,7 +953,17 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
||||
((MageActionCallback)callback).enlargeCard();
|
||||
((MageActionCallback)callback).enlargeCard(EnlargeMode.NORMAL);
|
||||
}
|
||||
});
|
||||
|
||||
KeyStroke ksAltS = KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.ALT_MASK);
|
||||
this.getInputMap(c).put(ksAltS, "ENLARGE_SOURCE");
|
||||
this.getActionMap().put("ENLARGE_SOURCE", new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
||||
((MageActionCallback)callback).enlargeCard(EnlargeMode.ALTERNATE);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -989,16 +1000,19 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
});
|
||||
|
||||
KeyStroke ksAltShiftReleased = KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK, true);
|
||||
this.getInputMap(c).put(ksAltShiftReleased, "ENLARGE_RELEASE");
|
||||
KeyStroke ksAltEReleased = KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK, true);
|
||||
this.getInputMap(c).put(ksAltEReleased, "ENLARGE_RELEASE");
|
||||
KeyStroke ksAltSReleased = KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.ALT_MASK, true);
|
||||
this.getInputMap(c).put(ksAltSReleased, "ENLARGE_RELEASE");
|
||||
this.getActionMap().put("ENLARGE_RELEASE", new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
||||
((MageActionCallback)callback).hideCard();
|
||||
((MageActionCallback)callback).hideEnlargedCard();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
btnSwitchHands.setText("Switch Hands");
|
||||
btnSwitchHands.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -34,13 +34,16 @@ import mage.client.util.ImageHelper;
|
|||
import mage.client.util.gui.ArrowBuilder;
|
||||
import mage.client.util.gui.GuiDisplayUtil;
|
||||
import mage.components.CardInfoPane;
|
||||
import mage.constants.EnlargeMode;
|
||||
import mage.remote.Session;
|
||||
import mage.utils.ThreadUtils;
|
||||
import mage.view.CardView;
|
||||
import mage.view.PermanentView;
|
||||
import mage.view.PlayerView;
|
||||
import mage.view.SimpleCardsView;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jdesktop.swingx.JXPanel;
|
||||
import org.mage.plugins.card.images.ImageCache;
|
||||
|
||||
public class MageActionCallback implements ActionCallback {
|
||||
|
||||
|
|
@ -54,13 +57,16 @@ public class MageActionCallback implements ActionCallback {
|
|||
private CardView popupCard;
|
||||
private TransferData popupData;
|
||||
private JComponent cardInfoPane;
|
||||
private volatile boolean state = false;
|
||||
private boolean enlarged = false;
|
||||
private volatile boolean popupTextWindowOpen = false;
|
||||
private volatile boolean enlargedImageWindowOpen = false;
|
||||
// shows the alternative card the normal card or the alternative card (copy source, other flip side, other transformed side)
|
||||
private volatile EnlargeMode enlargeMode;
|
||||
|
||||
private static final ScheduledExecutorService timeoutExecutor = Executors.newScheduledThreadPool(1);
|
||||
private ScheduledFuture<?> hideTimeout;
|
||||
|
||||
public MageActionCallback() {
|
||||
enlargeMode = EnlargeMode.NORMAL;
|
||||
}
|
||||
|
||||
public void setCardPreviewComponent(BigCard bigCard) {
|
||||
|
|
@ -227,7 +233,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
public void run() {
|
||||
ThreadUtils.sleep(300);
|
||||
|
||||
if (popupCard == null || !popupCard.equals(data.card) || session == null || !state || enlarged) {
|
||||
if (popupCard == null || !popupCard.equals(data.card) || session == null || !popupTextWindowOpen || enlargedImageWindowOpen) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +254,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!state || enlarged) {
|
||||
if (!popupTextWindowOpen || enlargedImageWindowOpen) {
|
||||
return;
|
||||
}
|
||||
popupContainer.setVisible(true);
|
||||
|
|
@ -265,7 +271,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e, TransferData data) {
|
||||
public void mouseMoved(MouseEvent e, TransferData transferData) {
|
||||
if (!Plugins.getInstance().isCardPluginLoaded()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -273,26 +279,32 @@ public class MageActionCallback implements ActionCallback {
|
|||
return;
|
||||
}
|
||||
|
||||
MageCard card = (MageCard) data.component;
|
||||
if (!state || card.getOriginal().getId() != bigCard.getCardId()) {
|
||||
MageCard mageCard = (MageCard) transferData.component;
|
||||
if (!popupTextWindowOpen || mageCard.getOriginal().getId() != bigCard.getCardId()) {
|
||||
if (bigCard.getWidth() > 0) {
|
||||
synchronized (MageActionCallback.class) {
|
||||
if (!state || card.getOriginal().getId() != bigCard.getCardId()) {
|
||||
if (!state) {
|
||||
if (!popupTextWindowOpen || mageCard.getOriginal().getId() != bigCard.getCardId()) {
|
||||
if (!popupTextWindowOpen) {
|
||||
bigCard.resetCardId();
|
||||
}
|
||||
state = true;
|
||||
Image image = card.getImage();
|
||||
displayCardInfo(card, image, bigCard);
|
||||
popupTextWindowOpen = true;
|
||||
Image image = mageCard.getImage();
|
||||
displayCardInfo(mageCard, image, bigCard);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
state = true;
|
||||
popupTextWindowOpen = true;
|
||||
}
|
||||
if (enlargedImageWindowOpen) {
|
||||
displayEnlargedCard(mageCard.getOriginal(), transferData);
|
||||
}
|
||||
displayCard(card.getOriginal(), data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the text popup window
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void hidePopup() {
|
||||
this.popupCard = null;
|
||||
|
|
@ -306,6 +318,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
// set enlarged card display to visible = false
|
||||
Component popupContainer = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
|
||||
popupContainer.setVisible(false);
|
||||
} catch (Exception e2) {
|
||||
|
|
@ -325,7 +338,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
public void hideAll(UUID gameId) {
|
||||
hidePopup();
|
||||
startHideTimeout();
|
||||
this.state = false;
|
||||
this.popupTextWindowOpen = false;
|
||||
if (gameId != null) {
|
||||
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.TARGET);
|
||||
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.PAIRED);
|
||||
|
|
@ -334,26 +347,49 @@ public class MageActionCallback implements ActionCallback {
|
|||
}
|
||||
}
|
||||
|
||||
public void enlargeCard() {
|
||||
if (!enlarged) {
|
||||
enlarged = true;
|
||||
CardView card = null;
|
||||
if (popupData != null) {
|
||||
card = popupData.card;
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent e, TransferData transferData) {
|
||||
if (enlargedImageWindowOpen) {
|
||||
hideEnlargedCard();
|
||||
return;
|
||||
}
|
||||
int notches = e.getWheelRotation();
|
||||
if (notches < 0) {
|
||||
// move up - show normal image
|
||||
|
||||
enlargeCard(EnlargeMode.NORMAL);
|
||||
|
||||
} else {
|
||||
// move down - show alternate image
|
||||
enlargeCard(EnlargeMode.ALTERNATE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the big card image on mouse position while hoovering over a card
|
||||
*
|
||||
* @param showAlternative defines if the original image (if it's a copied card) or the opposite side of a transformable card will be shown
|
||||
*/
|
||||
public void enlargeCard(EnlargeMode showAlternative) {
|
||||
if (!enlargedImageWindowOpen) {
|
||||
this.enlargeMode = showAlternative;
|
||||
CardView cardView = null;
|
||||
if (popupData != null) {
|
||||
cardView = popupData.card;
|
||||
}
|
||||
if (this.state) {
|
||||
if (this.popupTextWindowOpen) {
|
||||
hidePopup();
|
||||
}
|
||||
if (card != null) {
|
||||
displayCard(card, popupData);
|
||||
if (cardView != null) {
|
||||
enlargedImageWindowOpen = true;
|
||||
displayEnlargedCard(cardView, popupData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void hideCard() {
|
||||
if (enlarged) {
|
||||
enlarged = false;
|
||||
public void hideEnlargedCard() {
|
||||
if (enlargedImageWindowOpen) {
|
||||
enlargedImageWindowOpen = false;
|
||||
try {
|
||||
Component cardPreviewContainer = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_CONTAINER);
|
||||
cardPreviewContainer.setVisible(false);
|
||||
|
|
@ -363,52 +399,59 @@ public class MageActionCallback implements ActionCallback {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent e, TransferData data) {
|
||||
int notches = e.getWheelRotation();
|
||||
if (notches < 0) {
|
||||
enlargeCard();
|
||||
} else {
|
||||
hideCard();
|
||||
}
|
||||
}
|
||||
|
||||
private void displayCard(final CardView card, final TransferData data) {
|
||||
if (!enlarged) {
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
private void displayEnlargedCard(final CardView cardView, final TransferData transferData) {
|
||||
ThreadUtils.threadPool2.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (card == null) {
|
||||
if (cardView == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!enlarged) {
|
||||
if (!enlargedImageWindowOpen) {
|
||||
return;
|
||||
}
|
||||
|
||||
Component parentComponent = SwingUtilities.getRoot(data.component);
|
||||
Component parentComponent = SwingUtilities.getRoot(transferData.component);
|
||||
Point parentPoint = parentComponent.getLocationOnScreen();
|
||||
|
||||
final Component popupContainer = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_CONTAINER);
|
||||
Component cardPreview = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_PANE);
|
||||
if (cardPreview != null) {
|
||||
Point location = new Point((int) data.locationOnScreen.getX() + data.popupOffsetX - 40, (int) data.locationOnScreen.getY() + data.popupOffsetY - 40);
|
||||
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, cardPreview, parentComponent);
|
||||
Component cardPreviewPane = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_PANE);
|
||||
if (cardPreviewPane != null) {
|
||||
Point location = new Point((int) transferData.locationOnScreen.getX() + transferData.popupOffsetX - 40, (int) transferData.locationOnScreen.getY() + transferData.popupOffsetY - 40);
|
||||
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, cardPreviewPane, parentComponent);
|
||||
location.translate(-parentPoint.x, -parentPoint.y);
|
||||
popupContainer.setLocation(location);
|
||||
popupContainer.setVisible(true);
|
||||
|
||||
MageCard mageCard = (MageCard) transferData.component;
|
||||
Image image = null;
|
||||
switch (enlargeMode) {
|
||||
case COPY:
|
||||
if (cardView instanceof PermanentView) {
|
||||
image = ImageCache.getImageOriginal(((PermanentView) cardView).getOriginal());
|
||||
}
|
||||
break;
|
||||
case ALTERNATE:
|
||||
if (cardView.getAlternateName() != null) {
|
||||
if (cardView instanceof PermanentView && !cardView.isFlipCard() && !cardView.canTransform() && ((PermanentView) cardView).isCopy()) {
|
||||
image = ImageCache.getImageOriginal(((PermanentView) cardView).getOriginal());
|
||||
} else {
|
||||
image = ImageCache.getImageOriginalAlternateName(cardView);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (image == null) {
|
||||
image = mageCard.getImage();
|
||||
}
|
||||
// shows the card in the popup Container
|
||||
BigCard bigCard = (BigCard)cardPreviewPane;
|
||||
displayCardInfo(mageCard, image, bigCard);
|
||||
|
||||
|
||||
MageCard card = (MageCard) data.component;
|
||||
Image image = card.getImage();
|
||||
BigCard bigCard = (BigCard)cardPreview;
|
||||
displayCardInfo(card, image, bigCard);
|
||||
} else {
|
||||
Logger.getLogger(MageActionCallback.class).warn("No Card preview Pane in Mage Frame defined. Card: " + card.getName());
|
||||
logger.warn("No Card preview Pane in Mage Frame defined. Card: " + cardView.getName());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
|
@ -418,21 +461,22 @@ public class MageActionCallback implements ActionCallback {
|
|||
});
|
||||
}
|
||||
|
||||
private void displayCardInfo(MageCard card, Image image, BigCard bigCard) {
|
||||
private void displayCardInfo(MageCard mageCard, Image image, BigCard bigCard) {
|
||||
if (image != null && image instanceof BufferedImage) {
|
||||
// XXX: scaled to fit width
|
||||
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth());
|
||||
bigCard.setCard(card.getOriginal().getId(), image, card.getOriginal().getRules(), false);
|
||||
if (card.getOriginal().isAbility()) {
|
||||
bigCard.setCard(mageCard.getOriginal().getId(), enlargeMode, image, mageCard.getOriginal().getRules());
|
||||
// if it's an ability, show only the ability text as overlay
|
||||
if (mageCard.getOriginal().isAbility()) {
|
||||
bigCard.showTextComponent();
|
||||
} else {
|
||||
bigCard.hideTextComponent();
|
||||
}
|
||||
} else {
|
||||
JXPanel panel = GuiDisplayUtil.getDescription(card.getOriginal(), bigCard.getWidth(), bigCard.getHeight());
|
||||
JXPanel panel = GuiDisplayUtil.getDescription(mageCard.getOriginal(), bigCard.getWidth(), bigCard.getHeight());
|
||||
panel.setVisible(true);
|
||||
bigCard.hideTextComponent();
|
||||
bigCard.addJXPanel(card.getOriginal().getId(), panel);
|
||||
bigCard.addJXPanel(mageCard.getOriginal().getId(), panel);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -441,7 +485,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
hideTimeout = timeoutExecutor.schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
hideCard();
|
||||
hideEnlargedCard();
|
||||
}
|
||||
}, 700, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -379,7 +379,8 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
switch (usedPanel.getChatType()) {
|
||||
case GAME:
|
||||
usedPanel.receiveMessage("", new StringBuilder("You may use hot keys to play faster:")
|
||||
.append("\nTurn Mousewheel - Show big image of card your mousepointer hovers over")
|
||||
.append("\nTurn mousewheel up (ALT-e) - enlarge image of card the mousepointer hovers over")
|
||||
.append("\nTurn mousewheel down (ALT-s) - enlarge original/alternate image of card the mousepointer hovers over")
|
||||
.append("\nF2 - Confirm \"Ok\", \"Yes\" or \"Done\" button")
|
||||
.append("\nF4 - Skip current turn but stop on declare attackers/blockers and something on the stack")
|
||||
.append("\nF9 - Skip everything until your next turn")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue