mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
* GUI: fixed hybrid mana symbols download and render (#10082);
This commit is contained in:
parent
84ca77f5cb
commit
4274b75225
2 changed files with 42 additions and 27 deletions
|
@ -67,7 +67,7 @@ public final class ManaSymbols {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<String, Dimension> setImagesExist = new HashMap<>();
|
private static final Map<String, Dimension> setImagesExist = new HashMap<>();
|
||||||
private static final Pattern REPLACE_SYMBOLS_PATTERN = Pattern.compile("\\{([^}/]*)/?([^}]*)\\}");
|
private static final Pattern REPLACE_SYMBOLS_PATTERN = Pattern.compile("\\{([^}/]*)/?([^}/]*)/?([^}/]*)\\}");
|
||||||
|
|
||||||
private static final String[] symbols = new String[]{
|
private static final String[] symbols = new String[]{
|
||||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
||||||
|
@ -78,7 +78,8 @@ public final class ManaSymbols {
|
||||||
"S", "T", "Q",
|
"S", "T", "Q",
|
||||||
"U", "UB", "UR", "UP", "2U",
|
"U", "UB", "UR", "UP", "2U",
|
||||||
"W", "WB", "WU", "WP", "2W",
|
"W", "WB", "WU", "WP", "2W",
|
||||||
"X", "C", "E"};
|
"X", "C", "E",
|
||||||
|
"BGP", "BRP", "GUP", "GWP", "RGP", "RWP", "UBP", "URP", "WBP", "WUP"};
|
||||||
|
|
||||||
private static final JLabel labelRender = new JLabel(); // render mana text
|
private static final JLabel labelRender = new JLabel(); // render mana text
|
||||||
|
|
||||||
|
@ -651,7 +652,7 @@ public final class ManaSymbols {
|
||||||
|
|
||||||
replaced = replaced.replace(CardInfo.SPLIT_MANA_SEPARATOR_FULL, CardInfo.SPLIT_MANA_SEPARATOR_RENDER);
|
replaced = replaced.replace(CardInfo.SPLIT_MANA_SEPARATOR_FULL, CardInfo.SPLIT_MANA_SEPARATOR_RENDER);
|
||||||
replaced = REPLACE_SYMBOLS_PATTERN.matcher(replaced).replaceAll(
|
replaced = REPLACE_SYMBOLS_PATTERN.matcher(replaced).replaceAll(
|
||||||
"<img src='" + filePathToUrl(htmlImagesPath) + "$1$2" + ".png' alt='$1$2' width="
|
"<img src='" + filePathToUrl(htmlImagesPath) + "$1$2$3" + ".png' alt='$1$2$3' width="
|
||||||
+ symbolSize + " height=" + symbolSize + '>');
|
+ symbolSize + " height=" + symbolSize + '>');
|
||||||
|
|
||||||
// replace hint icons
|
// replace hint icons
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package org.mage.plugins.card.dl.sources;
|
package org.mage.plugins.card.dl.sources;
|
||||||
|
|
||||||
import com.google.common.collect.AbstractIterator;
|
import com.google.common.collect.AbstractIterator;
|
||||||
import java.io.File;
|
|
||||||
import static java.lang.String.format;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import mage.client.constants.Constants;
|
import mage.client.constants.Constants;
|
||||||
import org.mage.plugins.card.dl.DownloadJob;
|
import org.mage.plugins.card.dl.DownloadJob;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import static java.lang.String.format;
|
||||||
import static org.mage.plugins.card.dl.DownloadJob.fromURL;
|
import static org.mage.plugins.card.dl.DownloadJob.fromURL;
|
||||||
import static org.mage.plugins.card.dl.DownloadJob.toFile;
|
import static org.mage.plugins.card.dl.DownloadJob.toFile;
|
||||||
import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
|
import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
|
||||||
|
@ -13,10 +15,11 @@ import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
|
||||||
/**
|
/**
|
||||||
* The class GathererSymbols.
|
* The class GathererSymbols.
|
||||||
*
|
*
|
||||||
* @version V0.0 25.08.2010
|
|
||||||
* @author Clemens Koza
|
* @author Clemens Koza
|
||||||
|
* @version V0.0 25.08.2010
|
||||||
*/
|
*/
|
||||||
public class GathererSymbols implements Iterable<DownloadJob> {
|
public class GathererSymbols implements Iterable<DownloadJob> {
|
||||||
|
|
||||||
//TODO chaos and planeswalker symbol
|
//TODO chaos and planeswalker symbol
|
||||||
//chaos: https://gatherer.wizards.com/Images/Symbols/chaos.gif
|
//chaos: https://gatherer.wizards.com/Images/Symbols/chaos.gif
|
||||||
|
|
||||||
|
@ -53,10 +56,13 @@ public class GathererSymbols implements Iterable<DownloadJob> {
|
||||||
while (true) {
|
while (true) {
|
||||||
String sym;
|
String sym;
|
||||||
if (symIndex < symbols.length) {
|
if (symIndex < symbols.length) {
|
||||||
|
// take next char symbol
|
||||||
sym = symbols[symIndex++];
|
sym = symbols[symIndex++];
|
||||||
} else if (numeric <= maxNumeric) {
|
} else if (numeric <= maxNumeric) {
|
||||||
|
// take next numeric symbol
|
||||||
sym = String.valueOf(numeric++);
|
sym = String.valueOf(numeric++);
|
||||||
} else {
|
} else {
|
||||||
|
// switch to next size
|
||||||
sizeIndex++;
|
sizeIndex++;
|
||||||
if (sizeIndex == sizes.length) {
|
if (sizeIndex == sizes.length) {
|
||||||
return endOfData();
|
return endOfData();
|
||||||
|
@ -70,26 +76,34 @@ public class GathererSymbols implements Iterable<DownloadJob> {
|
||||||
String symbol = sym.replaceAll("/", "");
|
String symbol = sym.replaceAll("/", "");
|
||||||
File dst = new File(dir, symbol + ".gif");
|
File dst = new File(dir, symbol + ".gif");
|
||||||
|
|
||||||
/**
|
// workaround for miss icons on Gatherer (no cards with it, so no icons)
|
||||||
* Handle a bug on Gatherer where a few symbols are missing
|
// TODO: comment and try download without workaround, keep fix for symbols with "Resource not found" error
|
||||||
* at the large size. Fall back to using the medium symbol
|
switch (symbol) {
|
||||||
* for those cases.
|
case "WUP":
|
||||||
*/
|
case "BRP":
|
||||||
|
case "BGP":
|
||||||
|
case "WBP":
|
||||||
|
case "UBP":
|
||||||
|
case "URP":
|
||||||
|
// skip icon download
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// workaround for miss large size icons on Gatherer (replace it by medium size)
|
||||||
|
// TODO: comment and try download without workaround, keep fix for symbols with "Resource not found" error
|
||||||
int modSizeIndex = sizeIndex;
|
int modSizeIndex = sizeIndex;
|
||||||
if (sizeIndex == 2) {
|
if (sizeIndex == 2) {
|
||||||
switch (sym) {
|
switch (symbol) {
|
||||||
case "WP":
|
case "GUP":
|
||||||
case "UP":
|
case "GWP":
|
||||||
case "BP":
|
case "RGP":
|
||||||
case "RP":
|
case "RWP":
|
||||||
case "GP":
|
// need replace to medium size
|
||||||
case "E":
|
|
||||||
case "C":
|
|
||||||
modSizeIndex = 1;
|
modSizeIndex = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Nothing to do, symbol is available in the large size
|
// normal size
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue