mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
collection of old ungroupped pics has been fixed
This commit is contained in:
@@ -22,7 +22,6 @@ import java.util.HashMap;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
@@ -33,6 +32,7 @@ import forge.ImageCache;
|
|||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
import forge.card.CardRules;
|
import forge.card.CardRules;
|
||||||
|
import forge.card.CardSplitType;
|
||||||
import forge.card.EditionCollection;
|
import forge.card.EditionCollection;
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
@@ -294,36 +294,27 @@ public class MigrationSourceAnalyzer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void _addDefaultPicNames(CardPrinted c, boolean backFace) {
|
private void _addDefaultPicNames(CardPrinted c, boolean backFace) {
|
||||||
CardRules cardRules = c.getRules();
|
CardRules card = c.getRules();
|
||||||
String urls = backFace ? cardRules.getPictureOtherSideUrl() : cardRules.getPictureUrl();
|
String urls = backFace ? card.getPictureOtherSideUrl() : card.getPictureUrl();
|
||||||
if (StringUtils.isEmpty(urls)) { return; }
|
if (StringUtils.isEmpty(urls)) { return; }
|
||||||
|
|
||||||
int numPics = urls.split("\\\\").length;
|
int numPics = 1 + StringUtils.countMatches(urls, "\\");
|
||||||
if ( c.getArtIndex() >= numPics )
|
if ( c.getArtIndex() >= numPics )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String filename = ImageCache.getImageKey(c, backFace, false) + ".jpg";
|
String filenameBase = ImageCache.getImageKey(c, backFace, false);
|
||||||
_defaultPicNames.put(filename, filename);
|
String filename = filenameBase + ".jpg";
|
||||||
|
boolean alreadyHadIt = null != _defaultPicNames.put(filename, filename);
|
||||||
|
if ( alreadyHadIt ) return;
|
||||||
|
|
||||||
final String oldFilenameBase;
|
// Do you shift artIndex by one here?
|
||||||
if (cardRules.getType().isPlane() || cardRules.getType().isPhenomenon()) {
|
String newLastSymbol = 0 == c.getArtIndex() ? "" : String.valueOf(c.getArtIndex() /* + 1 */);
|
||||||
oldFilenameBase = _oldCleanString(filename.replace(".jpg", ""));
|
String oldFilename = _oldCleanString(filenameBase.replaceAll("[0-9]?(\\.full)?$", "")) + newLastSymbol + ".jpg";
|
||||||
} else {
|
//if ( numPics > 1 )
|
||||||
oldFilenameBase = _oldCleanString(filename.replace(".full.jpg", ""));
|
//System.out.printf("Will move %s -> %s%n", oldFilename, filename);
|
||||||
}
|
_defaultPicOldNameToCurrentName.put(oldFilename, filename);
|
||||||
|
|
||||||
int maxArtIdx = c.getRules().getEditionInfo(c.getEdition()).getCopiesCount();
|
|
||||||
if (1 == maxArtIdx) {
|
|
||||||
// remove trailing "1" from first art index
|
|
||||||
String oldFilename = oldFilenameBase.replaceAll("1$", "") + ".jpg";
|
|
||||||
_defaultPicOldNameToCurrentName.put(oldFilename, filename);
|
|
||||||
} else {
|
|
||||||
// offset art indices by one
|
|
||||||
String oldFilename = oldFilenameBase.replaceAll("[0-9]+$", String.valueOf(c.getArtIndex())) + ".jpg";
|
|
||||||
_defaultPicOldNameToCurrentName.put(oldFilename, filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Map<String, String> _defaultPicNames;
|
private Map<String, String> _defaultPicNames;
|
||||||
private Map<String, String> _defaultPicOldNameToCurrentName;
|
private Map<String, String> _defaultPicOldNameToCurrentName;
|
||||||
@@ -334,12 +325,13 @@ public class MigrationSourceAnalyzer {
|
|||||||
|
|
||||||
for (CardPrinted c : CardDb.instance().getAllCards()) {
|
for (CardPrinted c : CardDb.instance().getAllCards()) {
|
||||||
_addDefaultPicNames(c, false);
|
_addDefaultPicNames(c, false);
|
||||||
_addDefaultPicNames(c, true);
|
if ( c.getRules().getSplitType() == CardSplitType.Transform)
|
||||||
|
_addDefaultPicNames(c, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CardPrinted c : CardDb.variants().getAllCards()) {
|
for (CardPrinted c : CardDb.variants().getAllCards()) {
|
||||||
_addDefaultPicNames(c, false);
|
_addDefaultPicNames(c, false);
|
||||||
_addDefaultPicNames(c, true);
|
// variants never have backfaces
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,7 +340,7 @@ public class MigrationSourceAnalyzer {
|
|||||||
if (_defaultPicOldNameToCurrentName.containsKey(filename)) {
|
if (_defaultPicOldNameToCurrentName.containsKey(filename)) {
|
||||||
return _defaultPicOldNameToCurrentName.get(filename);
|
return _defaultPicOldNameToCurrentName.get(filename);
|
||||||
}
|
}
|
||||||
return _defaultPicNames.containsKey(filename) ? _defaultPicNames.get(filename) : null;
|
return _defaultPicNames.get(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public OpType getOpType(String filename) { return OpType.DEFAULT_CARD_PIC; }
|
@Override public OpType getOpType(String filename) { return OpType.DEFAULT_CARD_PIC; }
|
||||||
|
|||||||
Reference in New Issue
Block a user