diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/AltMtgOnlTokensImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/AltMtgOnlTokensImageSource.java index 17e5e962ca..96472c3467 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/AltMtgOnlTokensImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/AltMtgOnlTokensImageSource.java @@ -151,7 +151,18 @@ public enum AltMtgOnlTokensImageSource implements CardImageSource { return true; } + @Override + public boolean isCardSource() { + return false; + } + @Override public void doPause(String httpImageUrl) { } + + @Override + public boolean isCardImageProvided(String setCode, String cardName) { + // no cards support, only tokens + return false; + } } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CardImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CardImageSource.java index 3621a2a81d..f2f839ad34 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CardImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CardImageSource.java @@ -32,9 +32,9 @@ public interface CardImageSource { return 0; } - default boolean isTokenSource() { - return false; - } + boolean isCardSource(); + + boolean isTokenSource(); default boolean isLanguagesSupport() { return false; @@ -53,13 +53,8 @@ public interface CardImageSource { return new ArrayList<>(); } - default boolean isSetSupportedComplete(String setCode) { - return true; - } - default boolean isCardImageProvided(String setCode, String cardName) { - return false; - } + boolean isCardImageProvided(String setCode, String cardName); default boolean isTokenImageProvided(String setCode, String cardName, Integer tokenNumber) { return false; diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CopyPasteImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CopyPasteImageSource.java index dd3d991b9b..7b8883a7f1 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CopyPasteImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/CopyPasteImageSource.java @@ -21,8 +21,8 @@ public enum CopyPasteImageSource implements CardImageSource { instance; - private Set supportedSets = new LinkedHashSet(); - private Set missingCards = new LinkedHashSet(); + private final Set supportedSets = new LinkedHashSet(); + private final Set missingCards = new LinkedHashSet(); Map singleLinks = null; boolean loadedFromDialog = false; boolean viewMissingCards = true; @@ -221,7 +221,12 @@ public enum CopyPasteImageSource implements CardImageSource { @Override public boolean isTokenSource() { - return false; + return true; + } + + @Override + public boolean isCardSource() { + return true; } @Override @@ -254,9 +259,4 @@ public enum CopyPasteImageSource implements CardImageSource { public boolean isTokenImageProvided(String setCode, String cardName, Integer tokenNumber) { return false; } - - @Override - public boolean isSetSupportedComplete(String setCode) { - return false; - } } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GrabbagImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GrabbagImageSource.java index 24c4980db1..eb6c238415 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GrabbagImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GrabbagImageSource.java @@ -463,6 +463,11 @@ public enum GrabbagImageSource implements CardImageSource { return true; } + @Override + public boolean isCardSource() { + return true; + } + private String getSourceName(CardDownloadData card, String httpImageUrl) { if (card.getSet().equals("MTG")) { return "http://static.starcitygames.com/sales/cardscans/"; @@ -495,10 +500,4 @@ public enum GrabbagImageSource implements CardImageSource { } return singleLinks.containsKey(setCode + "/" + cardName) || singleLinks.containsKey(setCode + "/" + cardName + "-a"); } - - @Override - public boolean isSetSupportedComplete(String setCode) { - return false; - } - } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagidexImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagidexImageSource.java index 375194f18a..56d94b74e6 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagidexImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MagidexImageSource.java @@ -284,6 +284,11 @@ public enum MagidexImageSource implements CardImageSource { return false; } + @Override + public boolean isCardSource() { + return true; + } + @Override public void doPause(String httpImageUrl) { } @@ -292,4 +297,9 @@ public enum MagidexImageSource implements CardImageSource { public List getSupportedSets() { return new ArrayList<>(supportedSets); } + + @Override + public boolean isCardImageProvided(String setCode, String cardName) { + return supportedSets.contains(setCode); + } } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgOnlTokensImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgOnlTokensImageSource.java index c433c3eb5c..1b7a315d9d 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgOnlTokensImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgOnlTokensImageSource.java @@ -354,6 +354,11 @@ public enum MtgOnlTokensImageSource implements CardImageSource { return true; } + @Override + public boolean isCardSource() { + return false; + } + @Override public void doPause(String httpImageUrl) { } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MythicspoilerComSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MythicspoilerComSource.java index d7c9eec394..b14760ac21 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MythicspoilerComSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MythicspoilerComSource.java @@ -445,6 +445,11 @@ public enum MythicspoilerComSource implements CardImageSource { return false; } + @Override + public boolean isCardSource() { + return true; + } + @Override public void doPause(String httpImageUrl) { } @@ -454,4 +459,8 @@ public enum MythicspoilerComSource implements CardImageSource { return new ArrayList<>(supportedSets); } + @Override + public boolean isCardImageProvided(String setCode, String cardName) { + return supportedSets.contains(setCode); + } } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java index 0e4fb2d0d9..0cb327fa3a 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java @@ -219,6 +219,11 @@ public enum ScryfallImageSource implements CardImageSource { return true; } + @Override + public boolean isCardSource() { + return true; + } + @Override public boolean isLanguagesSupport() { return true; diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/TokensMtgImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/TokensMtgImageSource.java index c2b71e9cd1..5ab71beb8a 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/TokensMtgImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/TokensMtgImageSource.java @@ -146,6 +146,11 @@ public enum TokensMtgImageSource implements CardImageSource { return true; } + @Override + public boolean isCardSource() { + return false; + } + @Override public void doPause(String httpImageUrl) { } @@ -157,6 +162,7 @@ public enum TokensMtgImageSource implements CardImageSource { @Override public boolean isCardImageProvided(String setCode, String cardName) { + // no cards support, only tokens return false; } @@ -175,11 +181,6 @@ public enum TokensMtgImageSource implements CardImageSource { return (tokensData.containsKey(key)); } - @Override - public boolean isSetSupportedComplete(String setCode) { - return false; - } - private HashMap> getTokensData() throws IOException { synchronized (tokensDataSync) { if (tokensData == null) { diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java index eb108334ab..7adbb010cb 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java @@ -690,6 +690,11 @@ public enum WizardCardsImageSource implements CardImageSource { return false; } + @Override + public boolean isCardSource() { + return true; + } + @Override public boolean isLanguagesSupport() { return true; @@ -714,4 +719,9 @@ public enum WizardCardsImageSource implements CardImageSource { return new ArrayList<>(supportedSets); } + @Override + public boolean isCardImageProvided(String setCode, String cardName) { + return supportedSets.contains(setCode); + } + } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java index a268390dd9..01cf9461ae 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java @@ -272,9 +272,11 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements List setNames = new ArrayList<>(); // multiple sets selection - setNames.add(ALL_IMAGES); - setNames.add(ALL_MODERN_IMAGES); - setNames.add(ALL_STANDARD_IMAGES); + if (selectedSource.isCardSource()) { + setNames.add(ALL_IMAGES); + setNames.add(ALL_MODERN_IMAGES); + setNames.add(ALL_STANDARD_IMAGES); + } if (selectedSource.isTokenSource()) { setNames.add(ALL_TOKENS); } @@ -338,18 +340,17 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements int numberCardImagesAvailable = 0; for (CardDownloadData data : cardsMissing) { if (data.isToken()) { - if (selectedSource.isTokenSource() && selectedSource.isTokenImageProvided(data.getSet(), data.getName(), data.getType())) { + if (selectedSource.isTokenSource() + && selectedSource.isTokenImageProvided(data.getSet(), data.getName(), data.getType())) { numberTokenImagesAvailable++; cardsDownloadQueue.add(data); - } else { - //logger.warn("Source do not support token (set " + data.getSet() + ", token " + data.getName() + ")"); } } else { - if (selectedSets != null && selectedSets.contains(data.getSet())) { - if (selectedSource.isSetSupportedComplete(data.getSet()) || selectedSource.isCardImageProvided(data.getSet(), data.getName())) { - numberCardImagesAvailable++; - cardsDownloadQueue.add(data); - } + if (selectedSource.isCardSource() + && selectedSource.isCardImageProvided(data.getSet(), data.getName()) + && selectedSets.contains(data.getSet())) { + numberCardImagesAvailable++; + cardsDownloadQueue.add(data); } } }