mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-12 08:48:39 +00:00
transformed token image
This commit is contained in:
@@ -213,20 +213,17 @@ public class PaperToken implements InventoryItemFromSet, IPaperCard {
|
|||||||
// InventoryItem
|
// InventoryItem
|
||||||
@Override
|
@Override
|
||||||
public String getImageKey(boolean altState) {
|
public String getImageKey(boolean altState) {
|
||||||
if (hasBackFace()) {
|
String suffix = "";
|
||||||
String edCode = edition != null ? "_" + edition.getCode().toLowerCase() : "";
|
if (hasBackFace() && altState) {
|
||||||
if (altState) {
|
if (collectorNumber != null && !collectorNumber.isEmpty() && edition != null) {
|
||||||
String name = ImageKeys.getTokenKey(cardRules.getOtherPart().getName().toLowerCase().replace(" token", ""));
|
String name = cardRules.getOtherPart().getName().toLowerCase().replace(" token", "").replace(" ", "_");
|
||||||
name.replace(" ", "_");
|
return ImageKeys.getTokenKey(String.format("%s|%s|%s%s", name, edition.getCode(), collectorNumber, ImageKeys.BACKFACE_POSTFIX));
|
||||||
return name + edCode;
|
|
||||||
} else {
|
} else {
|
||||||
String name = ImageKeys.getTokenKey(cardRules.getMainPart().getName().toLowerCase().replace(" token", ""));
|
suffix = ImageKeys.BACKFACE_POSTFIX;
|
||||||
name.replace(" ", "_");
|
|
||||||
return name + edCode;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int idx = MyRandom.getRandom().nextInt(artIndex);
|
int idx = MyRandom.getRandom().nextInt(artIndex);
|
||||||
return getImageKey(idx);
|
return getImageKey(idx) + suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getImageKey(int artIndex) {
|
public String getImageKey(int artIndex) {
|
||||||
|
|||||||
@@ -197,9 +197,11 @@ public class ImageUtil {
|
|||||||
langCode, versionParam, faceParam);
|
langCode, versionParam, faceParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getScryfallTokenDownloadUrl(String collectorNumber, String setCode, String langCode) {
|
public static String getScryfallTokenDownloadUrl(String collectorNumber, String setCode, String langCode, String faceParam) {
|
||||||
String versionParam = "normal";
|
String versionParam = "normal";
|
||||||
String faceParam = "";
|
if (!faceParam.isEmpty()) {
|
||||||
|
faceParam = (faceParam.equals("back") ? "&face=back" : "&face=front");
|
||||||
|
}
|
||||||
return String.format("%s/%s/%s?format=image&version=%s%s", setCode, collectorNumber,
|
return String.format("%s/%s/%s?format=image&version=%s%s", setCode, collectorNumber,
|
||||||
langCode, versionParam, faceParam);
|
langCode, versionParam, faceParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ public abstract class ImageFetcher {
|
|||||||
boolean useArtCrop = "Crop".equals(FModel.getPreferences().getPref(ForgePreferences.FPref.UI_CARD_ART_FORMAT));
|
boolean useArtCrop = "Crop".equals(FModel.getPreferences().getPref(ForgePreferences.FPref.UI_CARD_ART_FORMAT));
|
||||||
final String prefix = imageKey.substring(0, 2);
|
final String prefix = imageKey.substring(0, 2);
|
||||||
File destFile = null;
|
File destFile = null;
|
||||||
|
String face = "";
|
||||||
if (prefix.equals(ImageKeys.CARD_PREFIX)) {
|
if (prefix.equals(ImageKeys.CARD_PREFIX)) {
|
||||||
PaperCard paperCard = ImageUtil.getPaperCardFromImageKey(imageKey);
|
PaperCard paperCard = ImageUtil.getPaperCardFromImageKey(imageKey);
|
||||||
if (paperCard == null) {
|
if (paperCard == null) {
|
||||||
@@ -144,7 +145,6 @@ public abstract class ImageFetcher {
|
|||||||
return;
|
return;
|
||||||
String imagePath = ImageUtil.getImageRelativePath(paperCard, "", true, false);
|
String imagePath = ImageUtil.getImageRelativePath(paperCard, "", true, false);
|
||||||
final boolean hasSetLookup = ImageKeys.hasSetLookup(imagePath);
|
final boolean hasSetLookup = ImageKeys.hasSetLookup(imagePath);
|
||||||
String face = "";
|
|
||||||
if (imageKey.endsWith(ImageKeys.BACKFACE_POSTFIX)) {
|
if (imageKey.endsWith(ImageKeys.BACKFACE_POSTFIX)) {
|
||||||
face = "back";
|
face = "back";
|
||||||
} else if (imageKey.endsWith(ImageKeys.SPECFACE_W)) {
|
} else if (imageKey.endsWith(ImageKeys.SPECFACE_W)) {
|
||||||
@@ -228,7 +228,12 @@ public abstract class ImageFetcher {
|
|||||||
this.getScryfallDownloadURL(paperCard, face, useArtCrop, hasSetLookup, filename, downloadUrls);
|
this.getScryfallDownloadURL(paperCard, face, useArtCrop, hasSetLookup, filename, downloadUrls);
|
||||||
}
|
}
|
||||||
} else if (prefix.equals(ImageKeys.TOKEN_PREFIX)) {
|
} else if (prefix.equals(ImageKeys.TOKEN_PREFIX)) {
|
||||||
String[] tempdata = imageKey.substring(2).split("\\|"); //We want to check the edition first.
|
String tmp = imageKey;
|
||||||
|
if (tmp.endsWith(ImageKeys.BACKFACE_POSTFIX)) {
|
||||||
|
face = "back";
|
||||||
|
tmp = tmp.substring(0, tmp.length() - ImageKeys.BACKFACE_POSTFIX.length());
|
||||||
|
}
|
||||||
|
String[] tempdata = tmp.substring(2).split("\\|"); //We want to check the edition first.
|
||||||
String tokenName = tempdata[0];
|
String tokenName = tempdata[0];
|
||||||
String setCode = tempdata[1];
|
String setCode = tempdata[1];
|
||||||
|
|
||||||
@@ -238,6 +243,9 @@ public abstract class ImageFetcher {
|
|||||||
sb.append(tempdata[2]).append("_");
|
sb.append(tempdata[2]).append("_");
|
||||||
}
|
}
|
||||||
sb.append(tokenName);
|
sb.append(tokenName);
|
||||||
|
if (tempdata.length <= 2 && !face.isEmpty()) {
|
||||||
|
sb.append("_").append(face);
|
||||||
|
}
|
||||||
sb.append(".jpg");
|
sb.append(".jpg");
|
||||||
|
|
||||||
final String filename = sb.toString();
|
final String filename = sb.toString();
|
||||||
@@ -264,7 +272,7 @@ public abstract class ImageFetcher {
|
|||||||
String tokenCode = edition.getTokensCode();
|
String tokenCode = edition.getTokensCode();
|
||||||
String langCode = edition.getCardsLangCode();
|
String langCode = edition.getCardsLangCode();
|
||||||
// just assume the CNr from the token image is valid
|
// just assume the CNr from the token image is valid
|
||||||
downloadUrls.add(ForgeConstants.URL_PIC_SCRYFALL_DOWNLOAD + ImageUtil.getScryfallTokenDownloadUrl(tempdata[2], tokenCode, langCode));
|
downloadUrls.add(ForgeConstants.URL_PIC_SCRYFALL_DOWNLOAD + ImageUtil.getScryfallTokenDownloadUrl(tempdata[2], tokenCode, langCode, face));
|
||||||
} else if (!allTokens.isEmpty()) {
|
} else if (!allTokens.isEmpty()) {
|
||||||
// This loop is going to try to download all the arts until it finds one
|
// This loop is going to try to download all the arts until it finds one
|
||||||
// This is a bit wrong since it _should_ just be trying to get the one with the appropriate collector number
|
// This is a bit wrong since it _should_ just be trying to get the one with the appropriate collector number
|
||||||
@@ -282,7 +290,7 @@ public abstract class ImageFetcher {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadUrls.add(ForgeConstants.URL_PIC_SCRYFALL_DOWNLOAD + ImageUtil.getScryfallTokenDownloadUrl(tis.collectorNumber(), tokenCode, langCode));
|
downloadUrls.add(ForgeConstants.URL_PIC_SCRYFALL_DOWNLOAD + ImageUtil.getScryfallTokenDownloadUrl(tis.collectorNumber(), tokenCode, langCode, face));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user