mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Download set lq pictures fixed for 2-faced
This commit is contained in:
@@ -680,6 +680,11 @@ public final class CardUtil {
|
|||||||
return buildFilename(card.getName(), card.getSet(), card.getArtIndex(), maxIndex, false);
|
return buildFilename(card.getName(), card.getSet(), card.getArtIndex(), maxIndex, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String buildFilename(final CardPrinted card, String nameToUse) {
|
||||||
|
int maxIndex = card.getCard().getSetInfo(card.getSet()).getCopiesCount();
|
||||||
|
return buildFilename(nameToUse, card.getSet(), card.getArtIndex(), maxIndex, false);
|
||||||
|
}
|
||||||
|
|
||||||
private static String buildFilename(final String cardName, final String setName, final int artIndex,
|
private static String buildFilename(final String cardName, final String setName, final int artIndex,
|
||||||
final int artIndexMax, final boolean isToken) {
|
final int artIndexMax, final boolean isToken) {
|
||||||
File path = ForgeProps.getFile(isToken ? NewConstants.IMAGE_TOKEN : NewConstants.IMAGE_BASE);
|
File path = ForgeProps.getFile(isToken ? NewConstants.IMAGE_TOKEN : NewConstants.IMAGE_BASE);
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ import forge.properties.NewConstants;
|
|||||||
public class GuiDownloadSetPicturesLQ extends GuiDownloader {
|
public class GuiDownloadSetPicturesLQ extends GuiDownloader {
|
||||||
|
|
||||||
private static final long serialVersionUID = -7890794857949935256L;
|
private static final long serialVersionUID = -7890794857949935256L;
|
||||||
|
private String picturesPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Constructor for Gui_DownloadSetPictures_LQ.
|
* Constructor for Gui_DownloadSetPictures_LQ.
|
||||||
@@ -35,8 +36,29 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader {
|
|||||||
*/
|
*/
|
||||||
public GuiDownloadSetPicturesLQ(final JFrame frame) {
|
public GuiDownloadSetPicturesLQ(final JFrame frame) {
|
||||||
super(frame);
|
super(frame);
|
||||||
|
picturesPath = ForgeProps.getFile(NewConstants.IMAGE_BASE).getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected final void addCardToList(ArrayList<DownloadObject> cList, CardPrinted c, String cardName)
|
||||||
|
{
|
||||||
|
final String urlBase = "http://cardforge.org/fpics/";
|
||||||
|
|
||||||
|
String setCode3 = c.getSet();
|
||||||
|
CardSet thisSet = SetUtils.getSetByCode(setCode3);
|
||||||
|
String setCode2 = thisSet.getCode2();
|
||||||
|
|
||||||
|
String imgFN = CardUtil.buildFilename(c, cardName);
|
||||||
|
boolean foundSetImage = imgFN.contains(setCode3) || imgFN.contains(setCode2);
|
||||||
|
|
||||||
|
if (!foundSetImage) {
|
||||||
|
int artsCnt = c.getCard().getSetInfo(setCode3).getCopiesCount();
|
||||||
|
String fn = CardUtil.buildIdealFilename(cardName, c.getArtIndex(), artsCnt);
|
||||||
|
cList.add(new DownloadObject(fn, urlBase + setCode2 + "/" + Base64Coder.encodeString(fn, true),
|
||||||
|
picturesPath + File.separator + setCode3));
|
||||||
|
System.out.println(String.format("%s [%s - %s]", cardName, setCode3, thisSet.getName() ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* getNeededCards.
|
* getNeededCards.
|
||||||
@@ -49,25 +71,16 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader {
|
|||||||
DownloadObject[] cardTokenLQ = readFileWithNames(NewConstants.TOKEN_IMAGES, ForgeProps.getFile(NewConstants.IMAGE_TOKEN));
|
DownloadObject[] cardTokenLQ = readFileWithNames(NewConstants.TOKEN_IMAGES, ForgeProps.getFile(NewConstants.IMAGE_TOKEN));
|
||||||
ArrayList<DownloadObject> cList = new ArrayList<DownloadObject>();
|
ArrayList<DownloadObject> cList = new ArrayList<DownloadObject>();
|
||||||
|
|
||||||
File base = ForgeProps.getFile(NewConstants.IMAGE_BASE);
|
|
||||||
String urlBase = "http://cardforge.org/fpics/";
|
|
||||||
for (CardPrinted c : CardDb.instance().getAllCards()) {
|
for (CardPrinted c : CardDb.instance().getAllCards()) {
|
||||||
String setCode3 = c.getSet();
|
String setCode3 = c.getSet();
|
||||||
if (StringUtils.isBlank(setCode3) || "???".equals(setCode3)) {
|
if (StringUtils.isBlank(setCode3) || "???".equals(setCode3)) {
|
||||||
continue; // we don't want cards from unknown sets
|
continue; // we don't want cards from unknown sets
|
||||||
}
|
}
|
||||||
|
|
||||||
CardSet thisSet = SetUtils.getSetByCode(setCode3);
|
addCardToList(cList, c, c.getCard().getName());
|
||||||
String setCode2 = thisSet.getCode2();
|
if ( c.getCard().isDoubleFaced() )
|
||||||
|
{
|
||||||
String imgFN = CardUtil.buildFilename(c);
|
addCardToList(cList, c, c.getCard().getSlavePart().getName());
|
||||||
boolean foundSetImage = imgFN.contains(setCode3) || imgFN.contains(setCode2);
|
|
||||||
|
|
||||||
if (!foundSetImage) {
|
|
||||||
int artsCnt = c.getCard().getSetInfo(setCode3).getCopiesCount();
|
|
||||||
String fn = CardUtil.buildIdealFilename(c.getName(), c.getArtIndex(), artsCnt);
|
|
||||||
cList.add(new DownloadObject(fn, urlBase + setCode2 + "/" + Base64Coder.encodeString(fn, true), base
|
|
||||||
.getPath() + File.separator + setCode3));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,9 @@ public final class CardRules {
|
|||||||
public String[] getRules() {
|
public String[] getRules() {
|
||||||
return characteristics.getCardRules();
|
return characteristics.getCardRules();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final CardRules getSlavePart() { return slavePart; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the sets printed.
|
* Gets the sets printed.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user