mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
* Fixed some problems with set icon download and displaying.
This commit is contained in:
parent
83679ea7a2
commit
5fe25b0af7
7 changed files with 164 additions and 135 deletions
|
|
@ -21,7 +21,6 @@ import mage.utils.CardUtil;
|
|||
import mage.view.CardView;
|
||||
import mage.view.CounterView;
|
||||
import mage.view.PermanentView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @author stravant@gmail.com
|
||||
|
|
@ -56,8 +55,6 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public abstract class CardRenderer {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(CardPanel.class);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Common layout metrics between all cards
|
||||
// The card to be rendered
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import java.nio.file.SimpleFileVisitor;
|
|||
import java.nio.file.StandardCopyOption;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
|
@ -38,6 +39,23 @@ public class ManaSymbols {
|
|||
private static boolean mediumSymbolsFound = false;
|
||||
|
||||
private static final Map<String, Map<String, Image>> setImages = new HashMap<>();
|
||||
|
||||
private static final HashSet<String> onlyMythics = new HashSet<>();
|
||||
private static final HashSet<String> withoutSymbols = new HashSet<>();
|
||||
|
||||
static {
|
||||
onlyMythics.add("DRB");
|
||||
onlyMythics.add("V09");
|
||||
onlyMythics.add("V12");
|
||||
onlyMythics.add("V13");
|
||||
onlyMythics.add("V14");
|
||||
onlyMythics.add("V15");
|
||||
onlyMythics.add("V16");
|
||||
onlyMythics.add("EXP");
|
||||
onlyMythics.add("MPS");
|
||||
|
||||
withoutSymbols.add("MPRP");
|
||||
}
|
||||
private static final Map<String, Dimension> setImagesExist = new HashMap<>();
|
||||
private static final Pattern REPLACE_SYMBOLS_PATTERN = Pattern.compile("\\{([^}/]*)/?([^}]*)\\}");
|
||||
private static String cachedPath;
|
||||
|
|
@ -57,7 +75,15 @@ public class ManaSymbols {
|
|||
return;
|
||||
}
|
||||
for (String set : setCodes) {
|
||||
String[] codes = new String[]{"C", "U", "R", "M"};
|
||||
if (withoutSymbols.contains(set)) {
|
||||
continue;
|
||||
}
|
||||
String[] codes;
|
||||
if (onlyMythics.contains(set)) {
|
||||
codes = new String[]{"M"};
|
||||
} else {
|
||||
codes = new String[]{"C", "U", "R", "M"};
|
||||
}
|
||||
|
||||
Map<String, Image> rarityImages = new HashMap<>();
|
||||
setImages.put(set, rarityImages);
|
||||
|
|
@ -72,7 +98,7 @@ public class ManaSymbols {
|
|||
if (h > 0) {
|
||||
Rectangle r = new Rectangle(21, (int) (h * 21.0f / width));
|
||||
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||
rarityImages.put(set, resized);
|
||||
rarityImages.put(rarityCode, resized);
|
||||
}
|
||||
} else {
|
||||
rarityImages.put(rarityCode, image);
|
||||
|
|
|
|||
|
|
@ -58,13 +58,16 @@ public class GathererSets implements Iterable<DownloadJob> {
|
|||
"KTK", "FRF", "DTK",
|
||||
"BFZ", "OGW",
|
||||
"SOI", "EMN",
|
||||
"KLD", "MPS", "AER",
|
||||
"KLD", "AER",
|
||||
"AKH", "HOU"
|
||||
};
|
||||
|
||||
private static final String[] onlyMythics = {
|
||||
"DRB", "V09", "V12", "V12", "V13", "V14", "V15", "V16", "EXP"
|
||||
};
|
||||
private static final String[] onlyMythicsAsSpecial = {
|
||||
"MPS"
|
||||
};
|
||||
|
||||
private static final HashMap<String, String> symbolsReplacements = new HashMap<>();
|
||||
|
||||
|
|
@ -93,6 +96,7 @@ public class GathererSets implements Iterable<DownloadJob> {
|
|||
symbolsReplacements.put("LEA", "1E");
|
||||
symbolsReplacements.put("LEB", "2E");
|
||||
symbolsReplacements.put("LEG", "LE");
|
||||
symbolsReplacements.put("MPS", "MPS_KLD");
|
||||
symbolsReplacements.put("MIR", "MI");
|
||||
symbolsReplacements.put("MMQ", "MM");
|
||||
symbolsReplacements.put("NEM", "NE");
|
||||
|
|
@ -129,35 +133,41 @@ public class GathererSets implements Iterable<DownloadJob> {
|
|||
for (String symbol : symbols) {
|
||||
ExpansionSet exp = Sets.findSet(symbol);
|
||||
if (exp != null && exp.getReleaseDate().before(compareDate)) {
|
||||
jobs.add(generateDownloadJob(symbol, "C"));
|
||||
jobs.add(generateDownloadJob(symbol, "U"));
|
||||
jobs.add(generateDownloadJob(symbol, "R"));
|
||||
jobs.add(generateDownloadJob(symbol, "C", "C"));
|
||||
jobs.add(generateDownloadJob(symbol, "U", "U"));
|
||||
jobs.add(generateDownloadJob(symbol, "R", "R"));
|
||||
}
|
||||
}
|
||||
for (String symbol : withMythics) {
|
||||
ExpansionSet exp = Sets.findSet(symbol);
|
||||
if (exp != null && exp.getReleaseDate().before(compareDate)) {
|
||||
jobs.add(generateDownloadJob(symbol, "C"));
|
||||
jobs.add(generateDownloadJob(symbol, "U"));
|
||||
jobs.add(generateDownloadJob(symbol, "R"));
|
||||
jobs.add(generateDownloadJob(symbol, "M"));
|
||||
jobs.add(generateDownloadJob(symbol, "C", "C"));
|
||||
jobs.add(generateDownloadJob(symbol, "U", "U"));
|
||||
jobs.add(generateDownloadJob(symbol, "R", "R"));
|
||||
jobs.add(generateDownloadJob(symbol, "M", "M"));
|
||||
}
|
||||
}
|
||||
for (String symbol : onlyMythics) {
|
||||
ExpansionSet exp = Sets.findSet(symbol);
|
||||
if (exp != null && exp.getReleaseDate().before(compareDate)) {
|
||||
jobs.add(generateDownloadJob(symbol, "M"));
|
||||
jobs.add(generateDownloadJob(symbol, "M", "M"));
|
||||
}
|
||||
}
|
||||
for (String symbol : onlyMythicsAsSpecial) {
|
||||
ExpansionSet exp = Sets.findSet(symbol);
|
||||
if (exp != null && exp.getReleaseDate().before(compareDate)) {
|
||||
jobs.add(generateDownloadJob(symbol, "M", "S"));
|
||||
}
|
||||
}
|
||||
return jobs.iterator();
|
||||
}
|
||||
|
||||
private DownloadJob generateDownloadJob(String set, String rarity) {
|
||||
private DownloadJob generateDownloadJob(String set, String rarity, String urlRarity) {
|
||||
File dst = new File(outDir, set + "-" + rarity + ".jpg");
|
||||
if (symbolsReplacements.containsKey(set)) {
|
||||
set = symbolsReplacements.get(set);
|
||||
}
|
||||
String url = "http://gatherer.wizards.com/Handlers/Image.ashx?type=symbol&set=" + set + "&size=small&rarity=" + rarity;
|
||||
String url = "http://gatherer.wizards.com/Handlers/Image.ashx?type=symbol&set=" + set + "&size=small&rarity=" + urlRarity;
|
||||
return new DownloadJob(set + "-" + rarity, fromURL(url), toFile(dst));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue