mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Issue #329: displaying a token image only from the same set, displaying magic card back image otherwise.
This commit is contained in:
parent
48445a4b87
commit
38d5a50b23
3 changed files with 16 additions and 4 deletions
|
|
@ -29,13 +29,15 @@ public class DirectLinksForDownload implements Iterable<DownloadJob> {
|
|||
|
||||
private static final Map<String, String> directLinks = new LinkedHashMap<String, String>();
|
||||
|
||||
public static final String cardbackFilename = "cardback.jpg";
|
||||
|
||||
static {
|
||||
directLinks.put("cardback.jpg", backsideUrl);
|
||||
directLinks.put(cardbackFilename, backsideUrl);
|
||||
}
|
||||
|
||||
private static final String DEFAULT_IMAGES_PATH = File.separator + "default";
|
||||
private static final File DEFAULT_OUT_DIR = new File("plugins" + File.separator + "images" + DEFAULT_IMAGES_PATH);
|
||||
private static File outDir = DEFAULT_OUT_DIR;
|
||||
public static File outDir = DEFAULT_OUT_DIR;
|
||||
|
||||
public DirectLinksForDownload(String path) {
|
||||
if (path == null) {
|
||||
|
|
|
|||
|
|
@ -11,11 +11,13 @@ import mage.client.dialog.PreferencesDialog;
|
|||
import mage.view.CardView;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.plugins.card.constants.Constants;
|
||||
import org.mage.plugins.card.dl.sources.DirectLinksForDownload;
|
||||
import org.mage.plugins.card.utils.CardImageUtils;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
|
@ -77,6 +79,9 @@ public class ImageCache {
|
|||
if (collectorId == 0) {
|
||||
info.setToken(true);
|
||||
path = CardImageUtils.generateTokenImagePath(info);
|
||||
if (path == null) {
|
||||
path = DirectLinksForDownload.outDir + File.separator + DirectLinksForDownload.cardbackFilename;
|
||||
}
|
||||
} else {
|
||||
path = CardImageUtils.generateImagePath(info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package org.mage.plugins.card.utils;
|
||||
|
||||
import de.schlichtherle.truezip.file.TFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import mage.client.constants.Constants;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import org.mage.plugins.card.dl.sources.DirectLinksForDownload;
|
||||
import org.mage.plugins.card.images.CardDownloadData;
|
||||
import org.mage.plugins.card.properties.SettingsManager;
|
||||
|
||||
|
|
@ -11,6 +14,7 @@ public class CardImageUtils {
|
|||
|
||||
private static HashMap<CardDownloadData, String> pathCache = new HashMap<CardDownloadData, String>();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return String if image exists, else null
|
||||
|
|
@ -23,10 +27,11 @@ public class CardImageUtils {
|
|||
String filePath = getTokenImagePath(card);
|
||||
TFile file = new TFile(filePath);
|
||||
|
||||
if (!file.exists()) {
|
||||
// Issue #329
|
||||
/*if (!file.exists()) {
|
||||
filePath = searchForCardImage(card);
|
||||
file = new TFile(filePath);
|
||||
}
|
||||
}*/
|
||||
|
||||
if (file.exists()) {
|
||||
pathCache.put(card, filePath);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue