mirror of
https://github.com/correl/mage.git
synced 2024-11-25 11:09:53 +00:00
Images download: fixed broken download dialog
This commit is contained in:
parent
2954bbaf04
commit
3bf0f80033
5 changed files with 14 additions and 13 deletions
|
@ -4,8 +4,6 @@ import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import mage.cards.ExpansionSet;
|
|
||||||
import mage.cards.Sets;
|
|
||||||
import mage.client.util.CardLanguage;
|
import mage.client.util.CardLanguage;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
@ -30,7 +28,7 @@ public enum ScryfallImageSource implements CardImageSource {
|
||||||
|
|
||||||
private final Map<CardLanguage, String> languageAliases;
|
private final Map<CardLanguage, String> languageAliases;
|
||||||
private CardLanguage currentLanguage = CardLanguage.ENGLISH; // working language
|
private CardLanguage currentLanguage = CardLanguage.ENGLISH; // working language
|
||||||
private Map<CardDownloadData, String> preparedUrls = new HashMap<>();
|
private final Map<CardDownloadData, String> preparedUrls = new HashMap<>();
|
||||||
|
|
||||||
ScryfallImageSource() {
|
ScryfallImageSource() {
|
||||||
// LANGUAGES
|
// LANGUAGES
|
||||||
|
@ -68,7 +66,7 @@ public enum ScryfallImageSource implements CardImageSource {
|
||||||
// TOKENS TRY
|
// TOKENS TRY
|
||||||
|
|
||||||
// tokens support only direct links
|
// tokens support only direct links
|
||||||
if (baseUrl == null && isToken) {
|
if (isToken) {
|
||||||
baseUrl = ScryfallImageSupportTokens.findTokenLink(card.getSet(), card.getName(), card.getType());
|
baseUrl = ScryfallImageSupportTokens.findTokenLink(card.getSet(), card.getName(), card.getType());
|
||||||
alternativeUrl = null;
|
alternativeUrl = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package org.mage.plugins.card.images;
|
package org.mage.plugins.card.images;
|
||||||
|
|
||||||
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import mage.util.CardUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public class CardDownloadData {
|
public class CardDownloadData {
|
||||||
|
@ -106,10 +106,7 @@ public class CardDownloadData {
|
||||||
if (this.secondSide != other.secondSide) {
|
if (this.secondSide != other.secondSide) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.isType2 != other.isType2) {
|
return this.isType2 == other.isType2;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -134,6 +131,12 @@ public class CardDownloadData {
|
||||||
return CardUtil.parseCardNumberAsInt(collectorId);
|
return CardUtil.parseCardNumberAsInt(collectorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCollectorIdAsFileName() {
|
||||||
|
// return file names compatible card number (e.g. replace special symbols)
|
||||||
|
return collectorId
|
||||||
|
.replace("*", "star");
|
||||||
|
}
|
||||||
|
|
||||||
public String getCollectorIdPostfix() {
|
public String getCollectorIdPostfix() {
|
||||||
return getCollectorId().replaceAll(getCollectorIdAsInt().toString(), "");
|
return getCollectorId().replaceAll(getCollectorIdAsInt().toString(), "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ public final class CardImageUtils {
|
||||||
String finalFileName = "";
|
String finalFileName = "";
|
||||||
if (card.getUsesVariousArt()) {
|
if (card.getUsesVariousArt()) {
|
||||||
// different arts uses name + collector id
|
// different arts uses name + collector id
|
||||||
finalFileName = cardName + prefixType + '.' + card.getCollectorId() + ".full.jpg";
|
finalFileName = cardName + prefixType + '.' + card.getCollectorIdAsFileName() + ".full.jpg";
|
||||||
} else {
|
} else {
|
||||||
// basic arts uses name
|
// basic arts uses name
|
||||||
finalFileName = cardName + prefixType + ".full.jpg";
|
finalFileName = cardName + prefixType + ".full.jpg";
|
||||||
|
|
Loading…
Reference in a new issue