mirror of
https://github.com/correl/mage.git
synced 2025-03-17 01:06:26 -09:00
Fixed a image cache problem that prevented to show cards with different art correctly.
This commit is contained in:
parent
5b544ef28b
commit
27acaa5c9a
2 changed files with 30 additions and 17 deletions
|
@ -63,7 +63,12 @@ public class CardPanelRenderImpl extends CardPanel {
|
||||||
if (!a.getRules().equals(b.getRules())) {
|
if (!a.getRules().equals(b.getRules())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!a.getRarity().equals(b.getRarity())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!a.getCardNumber().equals(b.getCardNumber())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// Expansion set code, with null checking:
|
// Expansion set code, with null checking:
|
||||||
// TODO: The null checks should not be necessary, but thanks to Issue #2260
|
// TODO: The null checks should not be necessary, but thanks to Issue #2260
|
||||||
// some tokens / commandobjects will be missing expansion set codes.
|
// some tokens / commandobjects will be missing expansion set codes.
|
||||||
|
@ -329,6 +334,7 @@ public class CardPanelRenderImpl extends CardPanel {
|
||||||
} else {
|
} else {
|
||||||
srcImage = ImageCache.getThumbnail(gameCard);
|
srcImage = ImageCache.getThumbnail(gameCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
UI.invokeLater(new Runnable() {
|
UI.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.mage.plugins.card.images;
|
package org.mage.plugins.card.images;
|
||||||
|
|
||||||
import mage.client.util.TransformedImageCache;
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.ComputationException;
|
import com.google.common.collect.ComputationException;
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.collect.MapMaker;
|
||||||
|
@ -13,6 +12,7 @@ import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
|
import mage.client.util.TransformedImageCache;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
import net.java.truevfs.access.TFile;
|
import net.java.truevfs.access.TFile;
|
||||||
import net.java.truevfs.access.TFileInputStream;
|
import net.java.truevfs.access.TFileInputStream;
|
||||||
|
@ -27,11 +27,12 @@ import org.mage.plugins.card.utils.CardImageUtils;
|
||||||
* that the images may be garbage collected when they are not needed any more,
|
* that the images may be garbage collected when they are not needed any more,
|
||||||
* but will be kept as long as possible.
|
* but will be kept as long as possible.
|
||||||
*
|
*
|
||||||
* Key format: "<cardname>#<setname>#<type>#<collectorID>#<param>"
|
* Key format: "[cardname]#[setname]#[type]#[collectorID]#[param]"
|
||||||
*
|
*
|
||||||
* where param is:
|
* where param is:
|
||||||
*
|
|
||||||
* <ul>
|
* <ul>
|
||||||
|
* <li>size of image</li>
|
||||||
|
*
|
||||||
* <li>#Normal: request for unrotated image</li>
|
* <li>#Normal: request for unrotated image</li>
|
||||||
* <li>#Tapped: request for rotated image</li>
|
* <li>#Tapped: request for rotated image</li>
|
||||||
* <li>#Cropped: request for cropped image that is used for Shandalar like card
|
* <li>#Cropped: request for cropped image that is used for Shandalar like card
|
||||||
|
@ -56,6 +57,7 @@ public class ImageCache {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
boolean usesVariousArt = false;
|
boolean usesVariousArt = false;
|
||||||
|
LOGGER.info("Key load to CACHE: " + key);
|
||||||
if (key.matches(".*#usesVariousArt.*")) {
|
if (key.matches(".*#usesVariousArt.*")) {
|
||||||
usesVariousArt = true;
|
usesVariousArt = true;
|
||||||
key = key.replace("#usesVariousArt", "");
|
key = key.replace("#usesVariousArt", "");
|
||||||
|
@ -127,7 +129,11 @@ public class ImageCache {
|
||||||
return makeThumbnailByFile(key, file, thumbnailPath);
|
return makeThumbnailByFile(key, file, thumbnailPath);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return getWizardsCard(loadImage(file));
|
BufferedImage image = loadImage(file);
|
||||||
|
LOGGER.info("Basic image: @" + Integer.toHexString(image.hashCode()));
|
||||||
|
image = getWizardsCard(image);
|
||||||
|
LOGGER.info("Wizard image: @" + Integer.toHexString(image.hashCode()));
|
||||||
|
return image;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
|
@ -237,8 +243,8 @@ public class ImageCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Image corresponding to the key only if it already exists
|
* Returns the Image corresponding to the key only if it already exists in
|
||||||
* in the cache.
|
* the cache.
|
||||||
*/
|
*/
|
||||||
private static BufferedImage tryGetImage(String key) {
|
private static BufferedImage tryGetImage(String key) {
|
||||||
if (IMAGE_CACHE.containsKey(key)) {
|
if (IMAGE_CACHE.containsKey(key)) {
|
||||||
|
@ -362,9 +368,10 @@ public class ImageCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the image appropriate to display for a card in a picture panel, but
|
* Returns the image appropriate to display for a card in a picture panel,
|
||||||
* only it was ALREADY LOADED. That is, the call is immediate and will not block
|
* but only it was ALREADY LOADED. That is, the call is immediate and will
|
||||||
* on file IO.
|
* not block on file IO.
|
||||||
|
*
|
||||||
* @param card
|
* @param card
|
||||||
* @param width
|
* @param width
|
||||||
* @param height
|
* @param height
|
||||||
|
|
Loading…
Add table
Reference in a new issue