From b3b54ffe00e6ef78be2b4deaee81e4e5b40e96f6 Mon Sep 17 00:00:00 2001 From: Agetian Date: Mon, 1 Jul 2013 10:05:54 +0000 Subject: [PATCH] - Foil cards will now show up as foil in the card picture panel during the match (but not in the deck editor, at least for now). --- src/main/java/forge/gui/CardPicturePanel.java | 27 +++++++++++++++++-- .../java/forge/view/arcane/CardPanel.java | 9 +++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/main/java/forge/gui/CardPicturePanel.java b/src/main/java/forge/gui/CardPicturePanel.java index 663108d6ff9..b19fc1de9ff 100644 --- a/src/main/java/forge/gui/CardPicturePanel.java +++ b/src/main/java/forge/gui/CardPicturePanel.java @@ -28,8 +28,13 @@ import javax.swing.JPanel; import forge.Card; import forge.ImageCache; +import forge.gui.toolbox.CardFaceSymbols; import forge.item.InventoryItem; +import forge.view.arcane.CardPanel; import forge.view.arcane.ScaledImagePanel; +import java.awt.image.ColorModel; +import java.awt.image.WritableRaster; +import javax.imageio.ImageIO; /** * The class CardPicturePanel. Shows the full-sized image in a label. if there's @@ -83,17 +88,35 @@ public final class CardPicturePanel extends JPanel { public void setImage() { final Insets i = this.getInsets(); BufferedImage image = null; + int foilIndex = 0; + if (displayed instanceof InventoryItem) { image = ImageCache.getImage((InventoryItem)this.displayed, this.getWidth() - i.left - i.right, this.getHeight() - i.top - i.bottom); } else if ( displayed instanceof Card ) { image = ImageCache.getImage((Card)this.displayed, this.getWidth() - i.left - i.right - 2, this.getHeight() - i.top - i.bottom - 2); + foilIndex = ((Card)this.displayed).getFoil(); } if (image != this.currentImage) { - this.currentImage = image; - this.panel.setImage(image); + if (foilIndex == 0) { + this.currentImage = image; + this.panel.setImage(image); + } else { + ColorModel cm = image.getColorModel(); + boolean isAlphaPremultiplied = cm.isAlphaPremultiplied(); + WritableRaster raster = image.copyData(null); + BufferedImage foilImage = new BufferedImage(cm, raster, isAlphaPremultiplied, null); + + final String fl = String.format("foil%02d", foilIndex); + final int z = Math.round(this.getWidth() * CardPanel.getBorderSize()); + CardFaceSymbols.drawOther(foilImage.getGraphics(), fl, z, z, this.panel.getWidth() - (2 * z), + this.panel.getHeight() - (2 * z)); + + this.currentImage = foilImage; + this.panel.setImage(foilImage); + } this.panel.repaint(); } } diff --git a/src/main/java/forge/view/arcane/CardPanel.java b/src/main/java/forge/view/arcane/CardPanel.java index 5134fd61788..7bba322ba90 100644 --- a/src/main/java/forge/view/arcane/CardPanel.java +++ b/src/main/java/forge/view/arcane/CardPanel.java @@ -765,4 +765,13 @@ public class CardPanel extends JPanel implements CardContainer { public final void setTappedAngle(final double tappedAngle0) { this.tappedAngle = tappedAngle0; } + + /** + * Gets the border size constant. + * + * @return BLACK_BORDER_SIZE + */ + public static final float getBorderSize() { + return BLACK_BORDER_SIZE; + } }