mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
GUI: fixed wrong options in download images dialog for some sources
This commit is contained in:
parent
f819340297
commit
c67e937dfb
11 changed files with 85 additions and 39 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -21,8 +21,8 @@ public enum CopyPasteImageSource implements CardImageSource {
|
|||
|
||||
instance;
|
||||
|
||||
private Set<String> supportedSets = new LinkedHashSet<String>();
|
||||
private Set<String> missingCards = new LinkedHashSet<String>();
|
||||
private final Set<String> supportedSets = new LinkedHashSet<String>();
|
||||
private final Set<String> missingCards = new LinkedHashSet<String>();
|
||||
Map<String, String> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String> getSupportedSets() {
|
||||
return new ArrayList<>(supportedSets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCardImageProvided(String setCode, String cardName) {
|
||||
return supportedSets.contains(setCode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -354,6 +354,11 @@ public enum MtgOnlTokensImageSource implements CardImageSource {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCardSource() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPause(String httpImageUrl) {
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,6 +219,11 @@ public enum ScryfallImageSource implements CardImageSource {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCardSource() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLanguagesSupport() {
|
||||
return true;
|
||||
|
|
|
@ -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<String, List<TokenData>> getTokensData() throws IOException {
|
||||
synchronized (tokensDataSync) {
|
||||
if (tokensData == null) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -272,9 +272,11 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
|
|||
List<String> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue