mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Fix to "download set LQ images" list of files
This commit is contained in:
@@ -499,6 +499,14 @@ public final class CardUtil {
|
|||||||
return !isNonStackingKeyword(keyword);
|
return !isNonStackingKeyword(keyword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String buildIdealFilename(final String cardName, final int artIndex, final int artIndexMax)
|
||||||
|
{
|
||||||
|
String nn = artIndexMax > 1 ? Integer.toString(artIndex+1) : "";
|
||||||
|
String mwsCardName = GuiDisplayUtil.cleanStringMWS(cardName);
|
||||||
|
//3 letter set code with MWS filename format
|
||||||
|
return String.format("%s%s.full.jpg", mwsCardName, nn);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* <p>buildFilename.</p>
|
* <p>buildFilename.</p>
|
||||||
*
|
*
|
||||||
@@ -518,10 +526,7 @@ public final class CardUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* buildFilename.
|
* buildFilename for lightweight card. Searches for a matching file on disk,
|
||||||
*
|
|
||||||
* @param card the card to get the filename for
|
|
||||||
* @return the filename
|
|
||||||
*/
|
*/
|
||||||
public static String buildFilename(final CardPrinted card) {
|
public static String buildFilename(final CardPrinted card) {
|
||||||
int maxIndex = card.getCard().getSetInfo(card.getSet()).getCopiesCount();
|
int maxIndex = card.getCard().getSetInfo(card.getSet()).getCopiesCount();
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
package forge;
|
package forge;
|
||||||
|
|
||||||
import com.esotericsoftware.minlog.Log;
|
import com.esotericsoftware.minlog.Log;
|
||||||
|
|
||||||
|
import forge.card.CardDb;
|
||||||
|
import forge.card.CardPrinted;
|
||||||
|
import forge.card.CardSet;
|
||||||
import forge.error.ErrorViewer;
|
import forge.error.ErrorViewer;
|
||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
@@ -8,6 +12,9 @@ import forge.properties.NewConstants;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
import javax.swing.event.ChangeListener;
|
import javax.swing.event.ChangeListener;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
@@ -386,66 +393,31 @@ public class Gui_DownloadSetPictures_LQ extends DefaultBoundedRangeModel impleme
|
|||||||
|
|
||||||
//File imgBase = ForgeProps.getFile(NewConstants.IMAGE_BASE);
|
//File imgBase = ForgeProps.getFile(NewConstants.IMAGE_BASE);
|
||||||
String URLBase = "http://cardforge.org/fpics/";
|
String URLBase = "http://cardforge.org/fpics/";
|
||||||
String imgFN = "";
|
|
||||||
|
|
||||||
for (Card c : AllZone.getCardFactory()) {
|
for (CardPrinted c : CardDb.instance().getAllCards()) {
|
||||||
ArrayList<SetInfo> cSetInfo = c.getSets();
|
String SC3 = c.getSet();
|
||||||
if (cSetInfo.size() > 0) {
|
if (StringUtils.isBlank(SC3) || "???".equals(SC3)) continue; // we don't want cards from unknown sets
|
||||||
for (int j = 0; j < cSetInfo.size(); j++) {
|
|
||||||
c.setCurSetCode(cSetInfo.get(j).Code);
|
|
||||||
String SC3 = c.getCurSetCode();
|
|
||||||
String SC2 = SetUtils.getCode2ByCode(c.getCurSetCode());
|
|
||||||
|
|
||||||
int n = 0;
|
CardSet thisSet = SetUtils.getSetByCode(SC3);
|
||||||
if (cSetInfo.get(j).PicCount > 0) {
|
String SC2 = thisSet.getCode2();
|
||||||
n = cSetInfo.get(j).PicCount;
|
|
||||||
|
|
||||||
for (int k = 1; k <= n; k++) {
|
String imgFN = CardUtil.buildFilename(c);
|
||||||
c.setRandomPicture(k);
|
boolean foundSetImage = imgFN.contains(SC3) || imgFN.contains(SC2);
|
||||||
|
|
||||||
imgFN = CardUtil.buildFilename(c);
|
|
||||||
if (imgFN.equals("none") || (!imgFN.contains(SC3) && !imgFN.contains(SC2))) {
|
|
||||||
String fn = GuiDisplayUtil.cleanStringMWS(c.getName()) + k + ".full.jpg";
|
|
||||||
CList.add(new mCard(SC3 + "/" + fn, URLBase + SC2 + "/" + Base64Coder.encodeString(fn, true), SC3));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
c.setRandomPicture(0);
|
|
||||||
|
|
||||||
imgFN = CardUtil.buildFilename(c);
|
|
||||||
if (imgFN.equals("none") || (!imgFN.contains(SC3) && !imgFN.contains(SC2))) {
|
|
||||||
String fn = GuiDisplayUtil.cleanStringMWS(c.getName()) + ".full.jpg";
|
|
||||||
//if (MyRandom.percentTrue(50))
|
|
||||||
CList.add(new mCard(SC3 + "/" + fn, URLBase + SC2 + "/" + Base64Coder.encodeString(fn, true), SC3));
|
|
||||||
//else
|
|
||||||
//CList.add(new mCard(SC3 + "/" + fn, c.getCurSetURL(), SC3));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!foundSetImage) {
|
||||||
|
int artsCnt = c.getCard().getSetInfo(SC3).getCopiesCount();
|
||||||
|
String fn = CardUtil.buildIdealFilename(c.getName(), c.getArtIndex(), artsCnt);
|
||||||
|
//System.out.println(fn);
|
||||||
|
CList.add(new mCard(SC3 + "/" + fn, URLBase + SC2 + "/" + Base64Coder.encodeString(fn, true), SC3));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Log.error(iName + ".jpg" + "\t" + URLs[0]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//ArrayList<mCard> list = new ArrayList<mCard>();
|
|
||||||
//File file;
|
|
||||||
|
|
||||||
//File base = ForgeProps.getFile(IMAGE_TOKEN);
|
|
||||||
//for (int i = 0; i < cardTokenLQ.length; i++) {
|
|
||||||
// file = new File(base, cardTokenLQ[i].name.substring(3, cardTokenLQ[i].name.length()));
|
|
||||||
// if (!file.exists()) CList.add(cardTokenLQ[i]);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//return all card names and urls that are needed
|
//return all card names and urls that are needed
|
||||||
mCard[] out = new mCard[CList.size()];
|
mCard[] out = new mCard[CList.size()];
|
||||||
CList.toArray(out);
|
CList.toArray(out);
|
||||||
|
|
||||||
for (int i = 0; i < out.length; i++)
|
for (int i = 0; i < out.length; i++) { System.out.println(out[i].name + " " + out[i].url); }
|
||||||
System.out.println(out[i].name + " " + out[i].url);
|
|
||||||
return out;
|
return out;
|
||||||
}//getNeededCards()
|
}//getNeededCards()
|
||||||
|
|
||||||
|
|||||||
@@ -153,10 +153,8 @@ 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
|
||||||
public Iterable<CardPrinted> getAllUniqueCards() {
|
public Iterable<CardPrinted> getAllUniqueCards() { return uniqueCards.values(); }
|
||||||
return uniqueCards.values();
|
//public Iterable<CardRules> getAllCardRules() { return cards.values(); } // still not needed
|
||||||
}
|
|
||||||
|
|
||||||
public Iterable<CardPrinted> getAllCards() { return allCardsFlat; }
|
public Iterable<CardPrinted> getAllCards() { return allCardsFlat; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user