- 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).

This commit is contained in:
Agetian
2013-07-01 10:05:54 +00:00
parent 43dae4915f
commit b3b54ffe00
2 changed files with 34 additions and 2 deletions

View File

@@ -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) {
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();
}
}

View File

@@ -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;
}
}