forked from External/mage
Card render testing dialog improves:
* Added chooseable render testing (click by mouse on cards); * Added column style render testing (many cards mode); * Added tapped, face down and manifested render testing for permanents; * CardView: fixed missing copy data (NPE for transformed cards); * CardArea: added support to draw permanents; * CardArea: added support of offsets between cards/columns;
This commit is contained in:
parent
a072d8275f
commit
eaaa37db11
27 changed files with 306 additions and 138 deletions
|
|
@ -84,6 +84,12 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
private boolean hasSickness;
|
||||
private String zone;
|
||||
|
||||
// Permanent and card renders are different (another sizes and positions of panel, tapped, etc -- that's weird)
|
||||
// Some card view components support only permanents (BattlefieldPanel), but another support only cards (CardArea)
|
||||
// TODO: remove crop/size logic from CardPanel to viewers panels or make compatible for all panels
|
||||
// But testing render needs both cards and permanents. That's settings allows to disable different render logic
|
||||
private boolean needFullPermanentRender = true;
|
||||
|
||||
public double transformAngle = 1;
|
||||
|
||||
private boolean transformed;
|
||||
|
|
@ -97,13 +103,27 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
// if this is set, it's opened if the user right clicks on the card panel
|
||||
private JPopupMenu popupMenu;
|
||||
|
||||
public CardPanel(CardView newGameCard, UUID gameId, final boolean loadImage, ActionCallback callback, final boolean foil, Dimension dimension) {
|
||||
public CardPanel(CardView newGameCard, UUID gameId, final boolean loadImage, ActionCallback callback, final boolean foil, Dimension dimension, boolean needFullPermanentRender) {
|
||||
// Store away params
|
||||
this.setGameCard(newGameCard);
|
||||
this.callback = callback;
|
||||
this.gameId = gameId;
|
||||
this.needFullPermanentRender = needFullPermanentRender;
|
||||
|
||||
// Gather info about the card
|
||||
/*
|
||||
this.setFocusable(true);
|
||||
this.addFocusListener(new java.awt.event.FocusAdapter() {
|
||||
public void focusGained(FocusEvent e) {
|
||||
//LOGGER.warn("focus gained " + getCard().getName());
|
||||
}
|
||||
|
||||
public void focusLost(FocusEvent e) {
|
||||
//LOGGER.warn("focus lost " + getCard().getName());
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
// Gather info about the card (all card maniputations possible with permanents only, also render can be different)
|
||||
this.isPermanent = this.getGameCard() instanceof PermanentView && !this.getGameCard().inViewerOnly();
|
||||
if (isPermanent) {
|
||||
this.hasSickness = ((PermanentView) this.getGameCard()).hasSummoningSickness();
|
||||
|
|
@ -204,7 +224,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
updateArtImage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setIsPermanent(boolean isPermanent) {
|
||||
this.isPermanent = isPermanent;
|
||||
}
|
||||
|
|
@ -360,7 +380,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
this.cardWidth = cardWidth;
|
||||
this.symbolWidth = cardWidth / 7;
|
||||
this.cardHeight = cardHeight;
|
||||
if (this.isPermanent) {
|
||||
if (this.isPermanent && needFullPermanentRender) {
|
||||
int rotCenterX = Math.round(cardWidth / 2f);
|
||||
int rotCenterY = cardHeight - rotCenterX;
|
||||
int rotCenterToTopCorner = Math.round(cardWidth * CardPanel.ROT_CENTER_TO_TOP_CORNER);
|
||||
|
|
@ -382,7 +402,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
}
|
||||
|
||||
public int getXOffset(int cardWidth) {
|
||||
if (this.isPermanent) {
|
||||
if (this.isPermanent && needFullPermanentRender) {
|
||||
int rotCenterX = Math.round(cardWidth / 2f);
|
||||
int rotCenterToBottomCorner = Math.round(cardWidth * CardPanel.ROT_CENTER_TO_BOTTOM_CORNER);
|
||||
int xOffset = rotCenterX - rotCenterToBottomCorner;
|
||||
|
|
@ -393,7 +413,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
}
|
||||
|
||||
public final int getYOffset(int cardWidth, int cardHeight) {
|
||||
if (this.isPermanent) {
|
||||
if (this.isPermanent && needFullPermanentRender) {
|
||||
int rotCenterX = Math.round(cardWidth / 2f);
|
||||
int rotCenterY = cardHeight - rotCenterX;
|
||||
int rotCenterToTopCorner = Math.round(cardWidth * CardPanel.ROT_CENTER_TO_TOP_CORNER);
|
||||
|
|
@ -625,7 +645,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
if (getGameCard().hideInfo()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (tooltipShowing) {
|
||||
synchronized (this) {
|
||||
if (tooltipShowing) {
|
||||
|
|
|
|||
|
|
@ -240,9 +240,9 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
}
|
||||
}
|
||||
|
||||
public CardPanelComponentImpl(CardView newGameCard, UUID gameId, final boolean loadImage, ActionCallback callback, final boolean foil, Dimension dimension) {
|
||||
public CardPanelComponentImpl(CardView newGameCard, UUID gameId, final boolean loadImage, ActionCallback callback, final boolean foil, Dimension dimension, boolean needFullPermanentRender) {
|
||||
// Call to super
|
||||
super(newGameCard, gameId, loadImage, callback, foil, dimension);
|
||||
super(newGameCard, gameId, loadImage, callback, foil, dimension, needFullPermanentRender);
|
||||
|
||||
// Counter panel
|
||||
if (!newGameCard.isAbility()) {
|
||||
|
|
@ -750,6 +750,7 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
}
|
||||
|
||||
private BufferedImage getFaceDownImage() {
|
||||
// TODO: add download default images
|
||||
if (isPermanent()) {
|
||||
if (((PermanentView) getGameCard()).isMorphed()) {
|
||||
return ImageCache.getMorphImage();
|
||||
|
|
|
|||
|
|
@ -231,9 +231,10 @@ public class CardPanelRenderImpl extends CardPanel {
|
|||
private BufferedImage cardImage;
|
||||
private CardRenderer cardRenderer;
|
||||
|
||||
public CardPanelRenderImpl(CardView newGameCard, UUID gameId, final boolean loadImage, ActionCallback callback, final boolean foil, Dimension dimension) {
|
||||
public CardPanelRenderImpl(CardView newGameCard, UUID gameId, final boolean loadImage, ActionCallback callback,
|
||||
final boolean foil, Dimension dimension, boolean needFullPermanentRender) {
|
||||
// Call to super
|
||||
super(newGameCard, gameId, loadImage, callback, foil, dimension);
|
||||
super(newGameCard, gameId, loadImage, callback, foil, dimension, needFullPermanentRender);
|
||||
|
||||
// Renderer
|
||||
cardRenderer = cardRendererFactory.create(getGameCard(), isTransformed());
|
||||
|
|
|
|||
|
|
@ -98,12 +98,12 @@ public class CardPluginImpl implements CardPlugin {
|
|||
* Temporary card rendering shim. Split card rendering isn't implemented
|
||||
* yet, so use old component based rendering for the split cards.
|
||||
*/
|
||||
private CardPanel makePanel(CardView view, UUID gameId, boolean loadImage, ActionCallback callback, boolean isFoil, Dimension dimension, int renderMode) {
|
||||
private CardPanel makePanel(CardView view, UUID gameId, boolean loadImage, ActionCallback callback, boolean isFoil, Dimension dimension, int renderMode, boolean needFullPermanentRender) {
|
||||
switch (renderMode) {
|
||||
case 0:
|
||||
return new CardPanelRenderImpl(view, gameId, loadImage, callback, isFoil, dimension);
|
||||
return new CardPanelRenderImpl(view, gameId, loadImage, callback, isFoil, dimension, needFullPermanentRender);
|
||||
case 1:
|
||||
return new CardPanelComponentImpl(view, gameId, loadImage, callback, isFoil, dimension);
|
||||
return new CardPanelComponentImpl(view, gameId, loadImage, callback, isFoil, dimension, needFullPermanentRender);
|
||||
default:
|
||||
throw new IllegalStateException("Unknown render mode " + renderMode);
|
||||
|
||||
|
|
@ -111,15 +111,15 @@ public class CardPluginImpl implements CardPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage, int renderMode) {
|
||||
CardPanel cardPanel = makePanel(permanent, gameId, loadImage, callback, false, dimension, renderMode);
|
||||
public MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage, int renderMode, boolean needFullPermanentRender) {
|
||||
CardPanel cardPanel = makePanel(permanent, gameId, loadImage, callback, false, dimension, renderMode, needFullPermanentRender);
|
||||
cardPanel.setShowCastingCost(true);
|
||||
return cardPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagePermanent getMageCard(CardView cardView, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage, int renderMode) {
|
||||
CardPanel cardPanel = makePanel(cardView, gameId, loadImage, callback, false, dimension, renderMode);
|
||||
public MagePermanent getMageCard(CardView cardView, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage, int renderMode, boolean needFullPermanentRender) {
|
||||
CardPanel cardPanel = makePanel(cardView, gameId, loadImage, callback, false, dimension, renderMode, needFullPermanentRender);
|
||||
cardPanel.setShowCastingCost(true);
|
||||
return cardPanel;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue