mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
fix downloaded filenames for cards with multiple default URLs
This commit is contained in:
@@ -19,7 +19,7 @@ final class ImageLoader extends CacheLoader<String, BufferedImage> {
|
|||||||
@Override
|
@Override
|
||||||
public BufferedImage load(String key) {
|
public BufferedImage load(String key) {
|
||||||
final String path;
|
final String path;
|
||||||
final String filename;
|
String filename;
|
||||||
if (key.startsWith(ImageCache.TOKEN_PREFIX)) {
|
if (key.startsWith(ImageCache.TOKEN_PREFIX)) {
|
||||||
filename = key.substring(ImageCache.TOKEN_PREFIX.length());
|
filename = key.substring(ImageCache.TOKEN_PREFIX.length());
|
||||||
path = NewConstants.CACHE_TOKEN_PICS_DIR;
|
path = NewConstants.CACHE_TOKEN_PICS_DIR;
|
||||||
@@ -49,9 +49,15 @@ final class ImageLoader extends CacheLoader<String, BufferedImage> {
|
|||||||
|
|
||||||
// try without set prefix
|
// try without set prefix
|
||||||
if (null == ret && filename.contains("/")) {
|
if (null == ret && filename.contains("/")) {
|
||||||
ret = _findFile(key, path, filename.substring(filename.indexOf('/') + 1));
|
filename = filename.substring(filename.indexOf('/') + 1);
|
||||||
|
ret = _findFile(key, path, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// // try lowering the art index to 0 for regular cards
|
||||||
|
// if (null == ret && filename.contains(".full.")) {
|
||||||
|
// ret = _findFile(key, path, filename.substring(filename.indexOf('/') + 1));
|
||||||
|
// }
|
||||||
|
|
||||||
if (null == ret) {
|
if (null == ret) {
|
||||||
System.out.println("File not found, no image created: " + key);
|
System.out.println("File not found, no image created: " + key);
|
||||||
}
|
}
|
||||||
@@ -59,24 +65,18 @@ final class ImageLoader extends CacheLoader<String, BufferedImage> {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BufferedImage getImage(final File file) {
|
|
||||||
BufferedImage image = null;;
|
|
||||||
try {
|
|
||||||
image = ImageIO.read(file);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
BugReporter.reportException(ex, "Could not read image file " + file.getAbsolutePath() + " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static BufferedImage _findFile(String key, String path, String filename) {
|
private static BufferedImage _findFile(String key, String path, String filename) {
|
||||||
for (String ext : _FILE_EXTENSIONS) {
|
for (String ext : _FILE_EXTENSIONS) {
|
||||||
File file = new File(path, filename + ext);
|
File file = new File(path, filename + ext);
|
||||||
//System.out.println(String.format("Searching for %s at: %s", key, file.getAbsolutePath()));
|
//System.out.println(String.format("Searching for %s at: %s", key, file.getAbsolutePath()));
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
//System.out.println(String.format("Found %s at: %s", key, file.getAbsolutePath()));
|
//System.out.println(String.format("Found %s at: %s", key, file.getAbsolutePath()));
|
||||||
return getImage(file);
|
try {
|
||||||
|
return ImageIO.read(file);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
BugReporter.reportException(ex, "Could not read image file " + file.getAbsolutePath() + " ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ public class CardFactory {
|
|||||||
}
|
}
|
||||||
else if (c.isDoubleFaced() && cp instanceof CardPrinted) {
|
else if (c.isDoubleFaced() && cp instanceof CardPrinted) {
|
||||||
c.setState(CardCharacteristicName.Transformed);
|
c.setState(CardCharacteristicName.Transformed);
|
||||||
c.setImageFilename(((CardPrinted)cp).getBackFaceImageFilename());
|
c.setImageFilename(((CardPrinted)cp).getImageFilename(true));
|
||||||
}
|
}
|
||||||
else if (c.getRules().getSplitType() == CardSplitType.Split) {
|
else if (c.getRules().getSplitType() == CardSplitType.Split) {
|
||||||
c.setState(CardCharacteristicName.LeftSplit);
|
c.setState(CardCharacteristicName.LeftSplit);
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class GameNew {
|
|||||||
if (preferences.getPrefBoolean(FPref.UI_RANDOM_CARD_ART)) {
|
if (preferences.getPrefBoolean(FPref.UI_RANDOM_CARD_ART)) {
|
||||||
final int cntVariants = cardPrinted.getRules().getEditionInfo(cardPrinted.getEdition()).getCopiesCount();
|
final int cntVariants = cardPrinted.getRules().getEditionInfo(cardPrinted.getEdition()).getCopiesCount();
|
||||||
if (cntVariants > 1) {
|
if (cntVariants > 1) {
|
||||||
card.setImageFilename(cardPrinted.getImageFilename(generator.nextInt(cntVariants)));
|
card.setImageFilename(cardPrinted.getImageFilename(false, generator.nextInt(cntVariants), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,13 +41,8 @@ public class GuiDownloadPicturesLQ extends GuiDownloader {
|
|||||||
Set<String> filenames = new HashSet<String>();
|
Set<String> filenames = new HashSet<String>();
|
||||||
|
|
||||||
for (final CardPrinted c : CardDb.instance().getUniqueCards()) {
|
for (final CardPrinted c : CardDb.instance().getUniqueCards()) {
|
||||||
CardRules cardRules = c.getRules();
|
addDLObject(c, false, downloads, filenames);
|
||||||
addDLObject(cardRules.getPictureUrl(), c.getImageFilename(), downloads, filenames);
|
addDLObject(c, true, downloads, filenames);
|
||||||
|
|
||||||
String backFaceImage = c.getBackFaceImageFilename();
|
|
||||||
if (backFaceImage != null) {
|
|
||||||
addDLObject(cardRules.getPictureOtherSideUrl(), backFaceImage, downloads, filenames);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add missing tokens to the list of things to download.
|
// Add missing tokens to the list of things to download.
|
||||||
@@ -60,16 +55,22 @@ public class GuiDownloadPicturesLQ extends GuiDownloader {
|
|||||||
return downloads;
|
return downloads;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addDLObject(String url, String filename, ArrayList<DownloadObject> downloads, Set<String> filenames) {
|
private void addDLObject(CardPrinted c, boolean backFace, ArrayList<DownloadObject> downloads, Set<String> filenames) {
|
||||||
if (StringUtils.isEmpty(url) || filenames.contains(filename)) {
|
CardRules cardRules = c.getRules();
|
||||||
|
String urls = backFace ? cardRules.getPictureOtherSideUrl() : cardRules.getPictureUrl();
|
||||||
|
if (StringUtils.isEmpty(urls)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
filenames.add(filename);
|
|
||||||
|
|
||||||
// remove set path prefix from card filename
|
int artIdx = -1;
|
||||||
if (filename.contains("/")) {
|
for (String url : urls.split("\\\\")) {
|
||||||
filename = filename.substring(filename.indexOf('/') + 1);
|
++artIdx;
|
||||||
|
|
||||||
|
String filename = c.getImageFilename(backFace, artIdx, false);
|
||||||
|
if (filenames.contains(filename)) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
filenames.add(filename);
|
||||||
|
|
||||||
File destFile = new File(NewConstants.CACHE_CARD_PICS_DIR, filename + ".jpg");
|
File destFile = new File(NewConstants.CACHE_CARD_PICS_DIR, filename + ".jpg");
|
||||||
if (!destFile.exists()) {
|
if (!destFile.exists()) {
|
||||||
@@ -77,3 +78,4 @@ public class GuiDownloadPicturesLQ extends GuiDownloader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader {
|
|||||||
|
|
||||||
addDLObject(c.getImageUrlPath(false), c.getImageFilename(), downloads);
|
addDLObject(c.getImageUrlPath(false), c.getImageFilename(), downloads);
|
||||||
|
|
||||||
String backFaceImage = c.getBackFaceImageFilename();
|
String backFaceImage = c.getImageFilename(true);
|
||||||
if (backFaceImage != null) {
|
if (backFaceImage != null) {
|
||||||
addDLObject(c.getImageUrlPath(true), backFaceImage, downloads);
|
addDLObject(c.getImageUrlPath(true), backFaceImage, downloads);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ public abstract class GuiDownloader extends DefaultBoundedRangeModel implements
|
|||||||
Log.error("LQ Pictures", "Error downloading pictures", ex);
|
Log.error("LQ Pictures", "Error downloading pictures", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// throttle -- why?
|
// throttle to reduce load on the server
|
||||||
try {
|
try {
|
||||||
Thread.sleep(r.nextInt(250) + 250);
|
Thread.sleep(r.nextInt(250) + 250);
|
||||||
} catch (final InterruptedException e) {
|
} catch (final InterruptedException e) {
|
||||||
@@ -370,21 +370,10 @@ public abstract class GuiDownloader extends DefaultBoundedRangeModel implements
|
|||||||
}
|
}
|
||||||
} // for
|
} // for
|
||||||
}
|
}
|
||||||
} // run
|
}
|
||||||
|
|
||||||
protected abstract ArrayList<DownloadObject> getNeededImages();
|
protected abstract ArrayList<DownloadObject> getNeededImages();
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* readFile.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param urlsFile
|
|
||||||
* a {@link java.lang.String} object.
|
|
||||||
* @param dir
|
|
||||||
* a {@link java.util.File} object.
|
|
||||||
* @return an array of {@link forge.gui.download.GuiDownloader.DownloadObject} objects.
|
|
||||||
*/
|
|
||||||
protected static List<DownloadObject> readFile(final String urlsFile, String dir) {
|
protected static List<DownloadObject> readFile(final String urlsFile, String dir) {
|
||||||
List<String> fileLines = FileUtil.readFile(urlsFile);
|
List<String> fileLines = FileUtil.readFile(urlsFile);
|
||||||
final ArrayList<DownloadObject> list = new ArrayList<DownloadObject>();
|
final ArrayList<DownloadObject> list = new ArrayList<DownloadObject>();
|
||||||
@@ -405,19 +394,8 @@ public abstract class GuiDownloader extends DefaultBoundedRangeModel implements
|
|||||||
list.add(new DownloadObject(line, new File(dir, replacer.matcher(last).replaceAll(" "))));
|
list.add(new DownloadObject(line, new File(dir, replacer.matcher(last).replaceAll(" "))));
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
} // readFile()
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* readFile.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param urlNamesFile
|
|
||||||
* a {@link java.lang.String} object.
|
|
||||||
* @param dir
|
|
||||||
* a {@link java.util.File} object.
|
|
||||||
* @return an array of {@link forge.gui.download.GuiDownloader.DownloadObject} objects.
|
|
||||||
*/
|
|
||||||
protected static ArrayList<DownloadObject> readFileWithNames(final String urlNamesFile, final String dir) {
|
protected static ArrayList<DownloadObject> readFileWithNames(final String urlNamesFile, final String dir) {
|
||||||
List<String> fileLines = FileUtil.readFile(urlNamesFile);
|
List<String> fileLines = FileUtil.readFile(urlNamesFile);
|
||||||
final ArrayList<DownloadObject> list = new ArrayList<DownloadObject>();
|
final ArrayList<DownloadObject> list = new ArrayList<DownloadObject>();
|
||||||
@@ -443,28 +421,10 @@ public abstract class GuiDownloader extends DefaultBoundedRangeModel implements
|
|||||||
protected class ProxyHandler implements ChangeListener {
|
protected class ProxyHandler implements ChangeListener {
|
||||||
private final int type;
|
private final int type;
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new proxy handler.
|
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
* the type
|
|
||||||
*/
|
|
||||||
public ProxyHandler(final int type) {
|
public ProxyHandler(final int type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.
|
|
||||||
* ChangeEvent)
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* State changed.
|
|
||||||
*
|
|
||||||
* @param e
|
|
||||||
* ChangeEvent
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public final void stateChanged(final ChangeEvent e) {
|
public final void stateChanged(final ChangeEvent e) {
|
||||||
if (((AbstractButton) e.getSource()).isSelected()) {
|
if (((AbstractButton) e.getSource()).isSelected()) {
|
||||||
@@ -502,5 +462,5 @@ public abstract class GuiDownloader extends DefaultBoundedRangeModel implements
|
|||||||
public File getDestination() {
|
public File getDestination() {
|
||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
} // DownloadObject
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,26 +38,12 @@ import forge.card.CardInSet;
|
|||||||
import forge.card.CardRules;
|
import forge.card.CardRules;
|
||||||
import forge.util.Aggregates;
|
import forge.util.Aggregates;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* CardDb class.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Forge
|
|
||||||
* @version $Id: CardDb.java 9708 2011-08-09 19:34:12Z jendave $
|
|
||||||
*/
|
|
||||||
public final class CardDb {
|
public final class CardDb {
|
||||||
private static volatile CardDb commonCards = null; // 'volatile' keyword makes this working
|
private static volatile CardDb commonCards = null; // 'volatile' keyword makes this working
|
||||||
private static volatile CardDb variantCards = null; // 'volatile' keyword makes this working
|
private static volatile CardDb variantCards = null; // 'volatile' keyword makes this working
|
||||||
public final static String foilSuffix = " foil";
|
public final static String foilSuffix = " foil";
|
||||||
private final static int foilSuffixLength = foilSuffix.length();
|
private final static int foilSuffixLength = foilSuffix.length();
|
||||||
|
|
||||||
/**
|
|
||||||
* Instance.
|
|
||||||
*
|
|
||||||
* @return the card db
|
|
||||||
*/
|
|
||||||
public static CardDb instance() {
|
public static CardDb instance() {
|
||||||
if (CardDb.commonCards == null) {
|
if (CardDb.commonCards == null) {
|
||||||
throw new NullPointerException("CardDb has not yet been initialized, run setup() first");
|
throw new NullPointerException("CardDb has not yet been initialized, run setup() first");
|
||||||
@@ -72,13 +58,6 @@ public final class CardDb {
|
|||||||
return CardDb.variantCards;
|
return CardDb.variantCards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the up.
|
|
||||||
*
|
|
||||||
* @param list
|
|
||||||
* the new up
|
|
||||||
*/
|
|
||||||
public static void setup(final Iterable<CardRules> list) {
|
public static void setup(final Iterable<CardRules> list) {
|
||||||
if (CardDb.commonCards != null) {
|
if (CardDb.commonCards != null) {
|
||||||
throw new RuntimeException("CardDb has already been initialized, don't do it twice please");
|
throw new RuntimeException("CardDb has already been initialized, don't do it twice please");
|
||||||
@@ -92,10 +71,6 @@ public final class CardDb {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here oracle cards
|
|
||||||
// private final Map<String, CardRules> cards = new Hashtable<String,
|
|
||||||
// CardRules>();
|
|
||||||
|
|
||||||
// Here are refs, get them by name
|
// Here are refs, get them by name
|
||||||
private final Map<String, CardPrinted> uniqueCards;
|
private final Map<String, CardPrinted> uniqueCards;
|
||||||
|
|
||||||
@@ -154,10 +129,6 @@ public final class CardDb {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is card supported.
|
* Checks if is card supported.
|
||||||
*
|
|
||||||
* @param cardName0
|
|
||||||
* the card name
|
|
||||||
* @return true, if is card supported
|
|
||||||
*/
|
*/
|
||||||
public CardPrinted tryGetCard(final String cardName0) {
|
public CardPrinted tryGetCard(final String cardName0) {
|
||||||
if (null == cardName0) {
|
if (null == cardName0) {
|
||||||
@@ -190,42 +161,15 @@ public final class CardDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Single fetch
|
// Single fetch
|
||||||
/**
|
|
||||||
* Gets the card.
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* the name
|
|
||||||
* @return the card
|
|
||||||
*/
|
|
||||||
public CardPrinted getCard(final String name) {
|
public CardPrinted getCard(final String name) {
|
||||||
return this.getCard(name, false);
|
return this.getCard(name, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Advanced fetch by name+set
|
// Advanced fetch by name+set
|
||||||
/**
|
|
||||||
* Gets the card.
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* the name
|
|
||||||
* @param set
|
|
||||||
* the set
|
|
||||||
* @return the card
|
|
||||||
*/
|
|
||||||
public CardPrinted getCard(final String name, final String set) {
|
public CardPrinted getCard(final String name, final String set) {
|
||||||
return this.getCard(name, set, 0);
|
return this.getCard(name, set, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the card.
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* the name
|
|
||||||
* @param set
|
|
||||||
* the set
|
|
||||||
* @param artIndex
|
|
||||||
* the art index
|
|
||||||
* @return the card
|
|
||||||
*/
|
|
||||||
public CardPrinted getCard(final String name, final String set, final int artIndex) {
|
public CardPrinted getCard(final String name, final String set, final int artIndex) {
|
||||||
// 1. get set
|
// 1. get set
|
||||||
final Map<String, CardPrinted[]> cardsFromset = this.allCardsBySet.get(set.toUpperCase());
|
final Map<String, CardPrinted[]> cardsFromset = this.allCardsBySet.get(set.toUpperCase());
|
||||||
@@ -252,13 +196,6 @@ public final class CardDb {
|
|||||||
|
|
||||||
// Fetch from Forge's Card instance. Well, there should be no errors, but
|
// Fetch from Forge's Card instance. Well, there should be no errors, but
|
||||||
// we'll still check
|
// we'll still check
|
||||||
/**
|
|
||||||
* Gets the card.
|
|
||||||
*
|
|
||||||
* @param forgeCard
|
|
||||||
* the forge card
|
|
||||||
* @return the card
|
|
||||||
*/
|
|
||||||
public static CardPrinted getCard(final Card forgeCard) {
|
public static CardPrinted getCard(final Card forgeCard) {
|
||||||
final String name = forgeCard.getName();
|
final String name = forgeCard.getName();
|
||||||
final String set = forgeCard.getCurSetCode();
|
final String set = forgeCard.getCurSetCode();
|
||||||
@@ -273,24 +210,10 @@ public final class CardDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// returns a list of all cards from their respective latest editions
|
// returns a list of all cards from their respective latest editions
|
||||||
/**
|
|
||||||
* Gets the all unique cards.
|
|
||||||
*
|
|
||||||
* @return the all unique cards
|
|
||||||
*/
|
|
||||||
public Collection<CardPrinted> getUniqueCards() {
|
public Collection<CardPrinted> getUniqueCards() {
|
||||||
return this.uniqueCards.values();
|
return this.uniqueCards.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// public Iterable<CardRules> getAllCardRules() { return cards.values(); }
|
|
||||||
// // still not needed
|
|
||||||
/**
|
|
||||||
* Gets the all cards.
|
|
||||||
*
|
|
||||||
* @return the all cards
|
|
||||||
*/
|
|
||||||
public List<CardPrinted> getAllCards() {
|
public List<CardPrinted> getAllCards() {
|
||||||
return this.allCardsFlat;
|
return this.allCardsFlat;
|
||||||
}
|
}
|
||||||
@@ -300,14 +223,6 @@ public final class CardDb {
|
|||||||
return Lists.newArrayList(Iterables.filter(this.allCardsFlat, predicate));
|
return Lists.newArrayList(Iterables.filter(this.allCardsFlat, predicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the card.
|
|
||||||
*
|
|
||||||
* @param name0 the name0
|
|
||||||
* @param fromLatestSet the from latest set
|
|
||||||
* @return the card
|
|
||||||
*/
|
|
||||||
public CardPrinted getCard(final String name0, final boolean fromLatestSet) {
|
public CardPrinted getCard(final String name0, final boolean fromLatestSet) {
|
||||||
// Sometimes they read from decks things like "CardName|Set" - but we
|
// Sometimes they read from decks things like "CardName|Set" - but we
|
||||||
// can handle it
|
// can handle it
|
||||||
@@ -344,10 +259,6 @@ public final class CardDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class CardSorter{
|
private static class CardSorter{
|
||||||
// Here oracle cards
|
|
||||||
// private final Map<String, CardRules> cards = new Hashtable<String,
|
|
||||||
// CardRules>();
|
|
||||||
|
|
||||||
// need this to obtain cardReference by name+set+artindex
|
// need this to obtain cardReference by name+set+artindex
|
||||||
public final Map<String, Map<String, CardPrinted[]>> allCommonCardsBySet = new TreeMap<String, Map<String, CardPrinted[]>>(String.CASE_INSENSITIVE_ORDER);
|
public final Map<String, Map<String, CardPrinted[]>> allCommonCardsBySet = new TreeMap<String, Map<String, CardPrinted[]>>(String.CASE_INSENSITIVE_ORDER);
|
||||||
public final Map<String, Map<String, CardPrinted[]>> allSpecialCardsBySet = new TreeMap<String, Map<String, CardPrinted[]>>(String.CASE_INSENSITIVE_ORDER);
|
public final Map<String, Map<String, CardPrinted[]>> allSpecialCardsBySet = new TreeMap<String, Map<String, CardPrinted[]>>(String.CASE_INSENSITIVE_ORDER);
|
||||||
@@ -358,17 +269,6 @@ public final class CardDb {
|
|||||||
public final List<CardPrinted> allCommonCardsFlat = new ArrayList<CardPrinted>();
|
public final List<CardPrinted> allCommonCardsFlat = new ArrayList<CardPrinted>();
|
||||||
public final List<CardPrinted> allSpecialCardsFlat = new ArrayList<CardPrinted>();
|
public final List<CardPrinted> allSpecialCardsFlat = new ArrayList<CardPrinted>();
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the to lists.
|
|
||||||
*
|
|
||||||
* @param card
|
|
||||||
* the card
|
|
||||||
* @param cardName
|
|
||||||
* the card name
|
|
||||||
* @param s
|
|
||||||
* the s
|
|
||||||
* @return the card printed
|
|
||||||
*/
|
|
||||||
public CardPrinted addToLists(final CardRules card, final String cardName, final String set, CardInSet cs) {
|
public CardPrinted addToLists(final CardRules card, final String cardName, final String set, CardInSet cs) {
|
||||||
CardPrinted lastAdded = null;
|
CardPrinted lastAdded = null;
|
||||||
|
|
||||||
@@ -396,12 +296,6 @@ public final class CardDb {
|
|||||||
return lastAdded;
|
return lastAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the new card.
|
|
||||||
*
|
|
||||||
* @param card
|
|
||||||
* the card
|
|
||||||
*/
|
|
||||||
private void addNewCard(final CardRules card) {
|
private void addNewCard(final CardRules card) {
|
||||||
if (null == card) {
|
if (null == card) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import forge.Singletons;
|
|||||||
import forge.card.CardRarity;
|
import forge.card.CardRarity;
|
||||||
import forge.card.CardRules;
|
import forge.card.CardRules;
|
||||||
import forge.card.CardSplitType;
|
import forge.card.CardSplitType;
|
||||||
import forge.card.ICardFace;
|
|
||||||
import forge.card.cardfactory.CardFactory;
|
import forge.card.cardfactory.CardFactory;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.util.Base64Coder;
|
import forge.util.Base64Coder;
|
||||||
@@ -134,43 +133,67 @@ public final class CardPrinted implements Comparable<IPaperCard>, InventoryItemF
|
|||||||
return out.toString();
|
return out.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getImageName() {
|
||||||
|
return CardSplitType.Split != card.getSplitType() ? name : card.getMainPart().getName() + card.getOtherPart().getName();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getImageFilename() {
|
public String getImageFilename() {
|
||||||
return getImageFilename(getArtIndex());
|
return getImageLocator(getImageName(), getArtIndex(), true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImageFilename(boolean backFace) {
|
||||||
|
return getImageFilename(backFace, getArtIndex(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImageFilename(boolean backFace, int artIdx, boolean includeSet) {
|
||||||
|
final String nameToUse;
|
||||||
|
if (backFace) {
|
||||||
|
if (null == card.getOtherPart()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
switch (card.getSplitType()) {
|
||||||
|
case Transform: case Flip: case Licid:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
nameToUse = card.getOtherPart().getName();
|
||||||
|
} else {
|
||||||
|
nameToUse = getImageName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return getImageLocator(nameToUse, artIdx, includeSet, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getImageUrlPath(boolean backFace) {
|
public String getImageUrlPath(boolean backFace) {
|
||||||
return getImageLocator(backFace ? card.getOtherPart().getName() : name, getArtIndex(), true);
|
return getImageLocator(backFace ? card.getOtherPart().getName() : getImageName(), getArtIndex(), true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getImageFilename(int artIdx) {
|
private String getImageLocator(String nameToUse, int artIdx, boolean includeSet, boolean base64encode) {
|
||||||
return getImageLocator(getArtIndex(), false);
|
StringBuilder s = new StringBuilder();
|
||||||
}
|
|
||||||
|
s.append(toMWSFilename(nameToUse));
|
||||||
|
|
||||||
private String getImageLocator(String nameToUse, int artIdx, boolean base64encode) {
|
|
||||||
int cntPictures = card.getEditionInfo(edition).getCopiesCount();
|
int cntPictures = card.getEditionInfo(edition).getCopiesCount();
|
||||||
nameToUse = toMWSFilename(nameToUse);
|
|
||||||
if (cntPictures > 1 && cntPictures > artIdx) {
|
if (cntPictures > 1 && cntPictures > artIdx) {
|
||||||
nameToUse += String.valueOf(artIdx + 1);
|
s.append(artIdx + 1);
|
||||||
}
|
}
|
||||||
nameToUse += ".full";
|
s.append(".full");
|
||||||
return String.format("%s/%s",
|
|
||||||
Singletons.getModel().getEditions().getCode2ByCode(edition),
|
final String fname;
|
||||||
base64encode ? Base64Coder.encodeString(nameToUse + ".jpg", true) : nameToUse);
|
if (base64encode) {
|
||||||
|
s.append(".jpg");
|
||||||
|
fname = Base64Coder.encodeString(s.toString(), true);
|
||||||
|
} else {
|
||||||
|
fname = s.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getImageLocator(int artIdx, boolean base64encode) {
|
if (includeSet) {
|
||||||
return getImageLocator(CardSplitType.Split == card.getSplitType() ? card.getMainPart().getName() + card.getOtherPart().getName() : name,
|
return String.format("%s/%s", Singletons.getModel().getEditions().getCode2ByCode(edition), fname);
|
||||||
artIdx, base64encode);
|
} else {
|
||||||
|
return fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBackFaceImageFilename() {
|
|
||||||
ICardFace backFace = card.getOtherPart();
|
|
||||||
if (null == backFace) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return getImageLocator(card.getOtherPart().getName(), getArtIndex(), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import javax.swing.JLabel;
|
|||||||
import javax.swing.JProgressBar;
|
import javax.swing.JProgressBar;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
|
|
||||||
import forge.gui.GuiDisplayUtil;
|
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user