This commit is contained in:
Evan Kranzler 2019-01-11 18:11:57 -05:00
commit 29549c62f5
7 changed files with 23 additions and 224 deletions

View file

@ -85,11 +85,6 @@ public class StackDialog extends IDialogPanel {
jTitle.setFont(new Font("Dialog", Font.BOLD, 14));
jTitle.setText("Current stack: ");
/*jTitle2 = new CustomLabel();
jTitle2.setBounds(new Rectangle(5, 5 + SettingsManager.getInstance().getCardSize().height + 30, 129, 20));
jTitle2.setFont(new Font("Dialog", Font.BOLD, 14));
jTitle2.setText("Spell targets:");*/
this.setLayout(null);
jLayeredPane.setLayout(null);

View file

@ -94,7 +94,6 @@ public final class Constants {
public interface IO {
String DEFAULT_IMAGES_DIR = "plugins" + File.separator + "images" + File.separator;
String IMAGE_PROPERTIES_FILE = "image.url.properties";
}
public enum DeckEditorMode {

View file

@ -18,7 +18,6 @@ import net.java.truevfs.access.TVFS;
import net.java.truevfs.kernel.spec.FsSyncException;
import org.apache.log4j.Logger;
import org.mage.plugins.card.dl.sources.*;
import org.mage.plugins.card.properties.SettingsManager;
import org.mage.plugins.card.utils.CardImageUtils;
import javax.swing.*;
@ -45,10 +44,10 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
private static DownloadPicturesService instance;
private static final Logger logger = Logger.getLogger(DownloadPicturesService.class);
public static final String ALL_IMAGES = "- ALL images from selected source (can be slow)";
public static final String ALL_MODERN_IMAGES = "- MODERN images (can be slow)";
public static final String ALL_STANDARD_IMAGES = "- STANDARD images";
public static final String ALL_TOKENS = "- TOKEN images";
private static final String ALL_IMAGES = "- ALL images from selected source (can be slow)";
private static final String ALL_MODERN_IMAGES = "- MODERN images (can be slow)";
private static final String ALL_STANDARD_IMAGES = "- STANDARD images";
private static final String ALL_TOKENS = "- TOKEN images";
private DownloadImagesDialog uiDialog;
private boolean needCancel;
@ -60,7 +59,7 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
private int missingCardsCount = 0;
private int missingTokensCount = 0;
List<String> selectedSets = new ArrayList<>();
private List<String> selectedSets = new ArrayList<>();
private static CardImageSource selectedSource;
private final Object sync = new Object();
@ -393,7 +392,6 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
}
private static List<CardDownloadData> prepareMissingCards(List<CardInfo> allCards, boolean redownloadMode) {
HashSet<String> ignoreUrls = SettingsManager.getIntance().getIgnoreUrls();
// get filter for Standard Type 2 cards
Set<String> type2SetsFilter = new HashSet<>();
@ -408,8 +406,7 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
List<CardDownloadData> allCardsUrls = Collections.synchronizedList(new ArrayList<>());
try {
allCards.parallelStream().forEach(card -> {
if (!card.getCardNumber().isEmpty() && !"0".equals(card.getCardNumber()) && !card.getSetCode().isEmpty()
&& !ignoreUrls.contains(card.getSetCode())) {
if (!card.getCardNumber().isEmpty() && !"0".equals(card.getCardNumber()) && !card.getSetCode().isEmpty()) {
String cardName = card.getName();
boolean isType2 = type2SetsFilter.contains(card.getSetCode());
CardDownloadData url = new CardDownloadData(cardName, card.getSetCode(), card.getCardNumber(), card.usesVariousArt(), 0, "", "", false, card.isDoubleFaced(), card.isNightCard());
@ -586,8 +583,6 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
}
if (p != null) {
HashSet<String> ignoreUrls = SettingsManager.getIntance().getIgnoreUrls();
update(0, cardsDownloadQueue.size());
logger.info("Started download of " + cardsDownloadQueue.size() + " images"
+ " from source: " + selectedSource.getSourceName()
@ -602,7 +597,7 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
logger.debug("Downloading image: " + card.getName() + " (" + card.getSet() + ')');
CardImageUrls urls;
if (ignoreUrls.contains(card.getSet()) || card.isToken()) {
if (card.isToken()) {
if (!"0".equals(card.getCollectorId())) {
continue;
}

View file

@ -1,76 +0,0 @@
package org.mage.plugins.card.properties;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Properties;
import mage.client.constants.Constants;
public class SettingsManager {
private static SettingsManager settingsManager = null;
public static synchronized SettingsManager getIntance() {
if (settingsManager == null) {
settingsManager = new SettingsManager();
}
return settingsManager;
}
private SettingsManager() {
loadImageProperties();
}
public void reloadImageProperties() {
loadImageProperties();
}
private void loadImageProperties() {
imageUrlProperties = new Properties();
try {
InputStream is = SettingsManager.class.getClassLoader().getResourceAsStream(Constants.IO.IMAGE_PROPERTIES_FILE);
if (is == null) {
throw new RuntimeException("Couldn't load " + Constants.IO.IMAGE_PROPERTIES_FILE);
}
imageUrlProperties.load(is);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
public String getSetNameReplacement(String setName) {
String result = setName;
if (imageUrlProperties != null) {
result = imageUrlProperties.getProperty(setName, setName);
}
return result;
}
public HashSet<String> getIgnoreUrls() {
HashSet<String> ignoreUrls = new HashSet<>();
if (imageUrlProperties != null) {
String result = imageUrlProperties.getProperty("ignore.urls");
if (result != null) {
String[] ignore = result.split(",");
ignoreUrls.addAll(Arrays.asList(ignore));
}
}
return ignoreUrls;
}
public ArrayList<String> getTokenLookupOrder() {
ArrayList<String> order = new ArrayList<>();
if (imageUrlProperties != null) {
String result = imageUrlProperties.getProperty("token.lookup.order");
if (result != null) {
String[] sets = result.split(",");
order.addAll(Arrays.asList(sets));
}
}
return order;
}
private Properties imageUrlProperties;
}

View file

@ -1,5 +1,16 @@
package org.mage.plugins.card.utils;
import mage.client.MageFrame;
import mage.client.constants.Constants;
import mage.client.dialog.PreferencesDialog;
import mage.remote.Connection;
import mage.remote.Connection.ProxyType;
import net.java.truevfs.access.TFile;
import org.apache.log4j.Logger;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.mage.plugins.card.images.CardDownloadData;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
@ -12,18 +23,6 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.prefs.Preferences;
import mage.client.MageFrame;
import mage.client.constants.Constants;
import mage.client.dialog.PreferencesDialog;
import mage.remote.Connection;
import mage.remote.Connection.ProxyType;
import net.java.truevfs.access.TFile;
import org.apache.log4j.Logger;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.mage.plugins.card.images.CardDownloadData;
import org.mage.plugins.card.properties.SettingsManager;
public final class CardImageUtils {
private static final HashMap<CardDownloadData, String> pathCache = new HashMap<>();
@ -53,7 +52,7 @@ public final class CardImageUtils {
return filePath;
}
log.warn("Token image file not found. Set: " + card.getSet() + " Token Set Code: " + card.getTokenSetCode() + " Name: " + card.getName() + " File path: " + filePath);
log.warn("Token image file not found. Set: " + card.getSet() + " Token Set Code: " + card.getTokenSetCode() + " Name: " + card.getName() + " File path: " + getTokenImagePath(card));
} else {
log.warn("Trying to get token path for non token card. Set: " + card.getSet() + " Set Code: " + card.getTokenSetCode() + " Name: " + card.getName());
}
@ -85,20 +84,6 @@ public final class CardImageUtils {
}
}
return filename;
// makes no longer sense
// file = new TFile(filename);
// if (!file.exists()) {
// CardDownloadData updated = new CardDownloadData(card);
// updated.setName(card.getName() + " 1");
// filename = buildImagePathToCard(updated);
// file = new TFile(filename);
// if (!file.exists()) {
// updated = new CardDownloadData(card);
// updated.setName(card.getName() + " 2");
// filename = buildImagePathToCard(updated);
// }
// }
}
private static String searchForCardImage(CardDownloadData card) {
@ -112,30 +97,9 @@ public final class CardImageUtils {
pathCache.put(card, path);
return path;
}
// for (String set : SettingsManager.getIntance().getTokenLookupOrder()) {
// c.setSet(set);
// path = getTokenImagePath(c);
// file = new TFile(path);
// if (file.exists()) {
// pathCache.put(card, path);
// return path;
// }
// }
return generateTokenDescriptorImagePath(card);
}
public static String updateSet(String cardSet, boolean forUrl) {
String set = cardSet.toLowerCase(Locale.ENGLISH);
if (set.equals("con")) {
set = "cfx";
}
if (forUrl) {
set = SettingsManager.getIntance().getSetNameReplacement(set);
}
return set;
}
public static String prepareCardNameForFile(String cardName) {
return cardName.replace(":", "").replace("\"", "").replace("//", "-");
}
@ -182,7 +146,7 @@ public final class CardImageUtils {
throw new IllegalArgumentException("Card " + card.getName() + " have empty set.");
}
String set = updateSet(card.getSet(), false).toUpperCase(Locale.ENGLISH); // TODO: research auto-replace... old code?
String set = card.getSet().toUpperCase(Locale.ENGLISH);
if (card.isToken()) {
return buildImagePathToSetAsToken(set);

View file

@ -1,78 +0,0 @@
tsp=ts
tor=tr
mor=mt
ody=od
lrw=lw
plc=pc
gpt=gp
inv=in
ons=on
scg=sc
jud=ju
mmq=mm
pls=ps
mrd=mi
mir=mr
tst=ts
usg=us
apc=ap
nem=ne
dis=di
vis=vi
9ed=9e
8ed=8e
7ed=7e
4ed=4e
tsb=tsts
ulg=ul
5ed=5e
6ed=6e
btd=bd
sth=sh
por=po
s99=st
lgn=le
ice=ia
csp=cs
tmp=tp
s00=st2k
dst=ds
pcy=pr
uds=ud
exo=ex
lea=al
hop=pch
chr=ch
arn=an
wth=wl
leb=be
2ed=un
3ed=rv
brb=br
atq=aq
fem=fe
leg=lg
hml=hl
all=ai
drk=dk
ptk=p3k
gur=guru
ddc=dvd
dd2=jvc
ddd=gvl
unh=uh
dde=pvc
v09=fve
v10=fvr
v11=fvl
drb=fvd
h09=pds
ugl=ug
dd3dvd=ddadvd
dd3evg=ddaevg
dd3gvl=ddagvl
dd3jvc=ddajvc
# Remove setname as soon as the images can be downloaded
ignore.urls=TOK,H17
# sets ordered by release time (newest goes first)
token.lookup.order=C18,M19,A25,DOM,E02,RIX,UST,XLN,IMA,H17,C17,V17,E01,DDT,CMA,HOU,MM3,DDS,AKH,DD3DVD,DD3EVG,DD3GVL,DD3JVC,H09,AER,PCA,C16,V16,MPS,KLD,DDR,CN2,EMN,EMA,SOI,DDQ,CP,CMA,ARENA,SUS,APAC,EURO,UGIN,C15,OGW,EXP,DDP,BFZ,DRB,V09,V10,V11,V12,V13,V14,V15,TPR,MPRP,DD3,DDO,ORI,MM2,PTC,DTK,FRF,KTK,M15,VMA,CNS,JOU,BNG,THS,DDL,M14,MMA,DGM,GTC,RTR,M13,AVR,DDI,DKA,ISD,M12,NPH,MBS,SOM,M11,ROE,DDE,WWK,ZEN,M10,GVL,ARB,DVD,CFX,JVC,ALA,EVE,SHM,EVG,MOR,LRW,10E,CLS,CHK,GRC

View file

@ -122,9 +122,9 @@ public final class IceAge extends ExpansionSet {
cards.add(new SetCardInfo("Formation", 25, Rarity.RARE, mage.cards.f.Formation.class));
cards.add(new SetCardInfo("Foul Familiar", 126, Rarity.COMMON, mage.cards.f.FoulFamiliar.class));
cards.add(new SetCardInfo("Foxfire", 238, Rarity.COMMON, mage.cards.f.Foxfire.class));
cards.add(new SetCardInfo("Freyalise Supplicant", 127, Rarity.UNCOMMON, mage.cards.f.FreyaliseSupplicant.class));
cards.add(new SetCardInfo("Freyalise Supplicant", 239, Rarity.UNCOMMON, mage.cards.f.FreyaliseSupplicant.class));
cards.add(new SetCardInfo("Freyalise's Charm", 240, Rarity.UNCOMMON, mage.cards.f.FreyalisesCharm.class));
cards.add(new SetCardInfo("Freyalise's Winds", 129, Rarity.RARE, mage.cards.f.FreyalisesWinds.class));
cards.add(new SetCardInfo("Freyalise's Winds", 241, Rarity.RARE, mage.cards.f.FreyalisesWinds.class));
cards.add(new SetCardInfo("Fumarole", 291, Rarity.UNCOMMON, mage.cards.f.Fumarole.class));
cards.add(new SetCardInfo("Fyndhorn Bow", 318, Rarity.UNCOMMON, mage.cards.f.FyndhornBow.class));
cards.add(new SetCardInfo("Fyndhorn Brownie", 242, Rarity.COMMON, mage.cards.f.FyndhornBrownie.class));
@ -245,7 +245,7 @@ public final class IceAge extends ExpansionSet {
cards.add(new SetCardInfo("Nature's Lore", 255, Rarity.UNCOMMON, mage.cards.n.NaturesLore.class));
cards.add(new SetCardInfo("Necropotence", 154, Rarity.RARE, mage.cards.n.Necropotence.class));
cards.add(new SetCardInfo("Norritt", 155, Rarity.COMMON, mage.cards.n.Norritt.class));
cards.add(new SetCardInfo("Oath of Lim-Dul", 44, Rarity.RARE, mage.cards.o.OathOfLimDul.class));
cards.add(new SetCardInfo("Oath of Lim-Dul", 156, Rarity.RARE, mage.cards.o.OathOfLimDul.class));
cards.add(new SetCardInfo("Onyx Talisman", 331, Rarity.UNCOMMON, mage.cards.o.OnyxTalisman.class));
cards.add(new SetCardInfo("Orcish Cannoneers", 205, Rarity.UNCOMMON, mage.cards.o.OrcishCannoneers.class));
cards.add(new SetCardInfo("Orcish Healer", 208, Rarity.UNCOMMON, mage.cards.o.OrcishHealer.class));