Fixed that token images were not loaded.

This commit is contained in:
LevelX2 2016-08-15 11:13:06 +02:00
parent 539b03bd1d
commit 873ecddb1d
2 changed files with 16 additions and 13 deletions

View file

@ -165,8 +165,8 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
private static Map<Key, BufferedImage> IMAGE_CACHE;
private final static class Key
{
private final static class Key {
final int width;
final int height;
final int cardWidth;
@ -476,10 +476,11 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
private void setImage(BufferedImage srcImage) {
synchronized (imagePanel) {
if(srcImage != null)
if (srcImage != null) {
imagePanel.setImage(srcImage);
else
} else {
imagePanel.clearImage();
}
repaint();
}
doLayout();
@ -570,7 +571,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D)(g.create());
Graphics2D g2d = (Graphics2D) (g.create());
if (alpha != 1.0f) {
AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha);
@ -730,7 +731,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
@Override
public final void setCardBounds(int x, int y, int cardWidth, int cardHeight) {
if(cardWidth == this.cardWidth && cardHeight == this.cardHeight) {
if (cardWidth == this.cardWidth && cardHeight == this.cardHeight) {
setBounds(x - cardXOffset, y - cardYOffset, getWidth(), getHeight());
return;
}
@ -757,8 +758,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
int height = cardYOffset * 2 + cardHeight;
setBounds(x - cardXOffset, y - cardYOffset, width, height);
}
if(imagePanel != null && imagePanel.getSrcImage() != null)
if (imagePanel != null && imagePanel.getSrcImage() != null) {
updateImage();
}
}
public int getXOffset(int cardWidth) {
@ -844,7 +846,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
tappedAngle = isTapped() ? CardPanel.TAPPED_ANGLE : 0;
flippedAngle = isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
final CardView gameCard = this.gameCard;
//final CardView gameCard = this.gameCard;
final int stamp = ++updateImageStamp;
Util.threadPool.submit(new Runnable() {
@ -861,8 +863,8 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
}
UI.invokeLater(new Runnable() {
@Override
public void run () {
if(stamp == updateImageStamp) {
public void run() {
if (stamp == updateImageStamp) {
hasImage = srcImage != null;
setText(gameCard);
setImage(srcImage);

View file

@ -4,9 +4,7 @@ import mage.client.util.TransformedImageCache;
import com.google.common.base.Function;
import com.google.common.collect.ComputationException;
import com.google.common.collect.MapMaker;
import com.mortennobel.imagescaling.ResampleOp;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
@ -74,6 +72,9 @@ public class ImageCache {
String set = m.group(2);
Integer type = Integer.parseInt(m.group(3));
String collectorId = m.group(4);
if (collectorId.equals("null")) {
collectorId = "0";
}
String tokenSetCode = m.group(5);
CardDownloadData info = new CardDownloadData(name, set, collectorId, usesVariousArt, type, tokenSetCode);
@ -340,7 +341,7 @@ public class ImageCache {
return original;
}
return TransformedImageCache.getResizedImage(original, (int)(original.getWidth() * scale), (int)(original.getHeight() * scale));
return TransformedImageCache.getResizedImage(original, (int) (original.getWidth() * scale), (int) (original.getHeight() * scale));
}
public static TFile getTFile(String path) {