mirror of
https://github.com/correl/mage.git
synced 2024-12-26 19:16:54 +00:00
* Some fixes to token image downloading.
This commit is contained in:
parent
7e99a027d2
commit
c9603d1994
14 changed files with 231 additions and 255 deletions
|
@ -24,7 +24,7 @@
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
package mage.client.deckeditor.collection.viewer;
|
package mage.client.deckeditor.collection.viewer;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
@ -48,7 +48,6 @@ import mage.client.util.gui.FastSearchUtil;
|
||||||
import mage.client.util.sets.ConstructedFormats;
|
import mage.client.util.sets.ConstructedFormats;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pane with big card and mage book.
|
* Pane with big card and mage book.
|
||||||
*
|
*
|
||||||
|
@ -117,6 +116,7 @@ public final class CollectionViewerPanel extends JPanel {
|
||||||
btnSetFastSearch.setPreferredSize(new java.awt.Dimension(32, 32));
|
btnSetFastSearch.setPreferredSize(new java.awt.Dimension(32, 32));
|
||||||
btnSetFastSearch.setMaximumSize(new java.awt.Dimension(32, 32));
|
btnSetFastSearch.setMaximumSize(new java.awt.Dimension(32, 32));
|
||||||
btnSetFastSearch.addActionListener(new java.awt.event.ActionListener() {
|
btnSetFastSearch.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
@Override
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
FastSearchUtil.showFastSearchForStringComboBox(formats, FastSearchUtil.DEFAULT_EXPANSION_SEARCH_MESSAGE);
|
FastSearchUtil.showFastSearchForStringComboBox(formats, FastSearchUtil.DEFAULT_EXPANSION_SEARCH_MESSAGE);
|
||||||
}
|
}
|
||||||
|
@ -169,20 +169,21 @@ public final class CollectionViewerPanel extends JPanel {
|
||||||
next.addActionListener(e -> mageBook.next());
|
next.addActionListener(e -> mageBook.next());
|
||||||
buttonPanel.add(next);
|
buttonPanel.add(next);
|
||||||
|
|
||||||
JLabel label4 = new JLabel("Show cards or tokens:");
|
JLabel labelCardTokenSwitch = new JLabel("Show cards or tokens:");
|
||||||
label3.setAlignmentX(Component.LEFT_ALIGNMENT);
|
labelCardTokenSwitch.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||||
label3.setForeground(Color.white);
|
labelCardTokenSwitch.setForeground(Color.white);
|
||||||
buttonsPanel.add(label4);
|
buttonsPanel.add(labelCardTokenSwitch);
|
||||||
|
|
||||||
JCheckBox cardsOrTokens = new JCheckBox("Display Cards");
|
JCheckBox cardsOrTokens = new JCheckBox("Display Cards");
|
||||||
cardsOrTokens.setSelected(true);
|
cardsOrTokens.setSelected(true);
|
||||||
|
cardsOrTokens.setForeground(Color.white);
|
||||||
cardsOrTokens.setToolTipText("Select to show Cards or Tokens(and emblems) for the chosen set");
|
cardsOrTokens.setToolTipText("Select to show Cards or Tokens(and emblems) for the chosen set");
|
||||||
cardsOrTokens.addActionListener(e -> mageBook.cardsOrTokens(cardsOrTokens.isSelected()));
|
cardsOrTokens.addActionListener(e -> mageBook.cardsOrTokens(cardsOrTokens.isSelected()));
|
||||||
buttonsPanel.add(cardsOrTokens);
|
buttonsPanel.add(cardsOrTokens);
|
||||||
|
|
||||||
formats.addActionListener(e -> {
|
formats.addActionListener(e -> {
|
||||||
if (mageBook != null) {
|
if (mageBook != null) {
|
||||||
String format = (String)formats.getSelectedItem();
|
String format = (String) formats.getSelectedItem();
|
||||||
MageFrame.getPreferences().put(CollectionViewerPanel.FORMAT_CONFIG_KEY, format);
|
MageFrame.getPreferences().put(CollectionViewerPanel.FORMAT_CONFIG_KEY, format);
|
||||||
mageBook.updateDispayedSets(format);
|
mageBook.updateDispayedSets(format);
|
||||||
}
|
}
|
||||||
|
@ -233,11 +234,13 @@ public final class CollectionViewerPanel extends JPanel {
|
||||||
c = c.getParent();
|
c = c.getParent();
|
||||||
}
|
}
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
((CollectionViewerPane)c).removeFrame();
|
((CollectionViewerPane) c).removeFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class MageBookContainer extends JPanel {
|
private final class MageBookContainer extends JPanel {
|
||||||
|
|
||||||
public MageBookContainer() {
|
public MageBookContainer() {
|
||||||
super();
|
super();
|
||||||
initComponents();
|
initComponents();
|
||||||
|
@ -246,7 +249,7 @@ public final class CollectionViewerPanel extends JPanel {
|
||||||
public void initComponents() {
|
public void initComponents() {
|
||||||
jPanel = new JPanel();
|
jPanel = new JPanel();
|
||||||
jScrollPane1 = new JScrollPane(jPanel);
|
jScrollPane1 = new JScrollPane(jPanel);
|
||||||
jScrollPane1.getViewport().setBackground(new Color(0,0,0,0));
|
jScrollPane1.getViewport().setBackground(new Color(0, 0, 0, 0));
|
||||||
|
|
||||||
jPanel.setLayout(new GridBagLayout()); // centers mage book
|
jPanel.setLayout(new GridBagLayout()); // centers mage book
|
||||||
jPanel.setBackground(new Color(0, 0, 0, 0));
|
jPanel.setBackground(new Color(0, 0, 0, 0));
|
||||||
|
|
|
@ -27,6 +27,19 @@
|
||||||
*/
|
*/
|
||||||
package mage.client.deckeditor.collection.viewer;
|
package mage.client.deckeditor.collection.viewer;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import static java.lang.Math.min;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.*;
|
||||||
import mage.cards.*;
|
import mage.cards.*;
|
||||||
import mage.cards.repository.CardCriteria;
|
import mage.cards.repository.CardCriteria;
|
||||||
import mage.cards.repository.CardInfo;
|
import mage.cards.repository.CardInfo;
|
||||||
|
@ -42,29 +55,15 @@ import mage.client.util.sets.ConstructedFormats;
|
||||||
import mage.components.ImagePanel;
|
import mage.components.ImagePanel;
|
||||||
import mage.components.ImagePanelStyle;
|
import mage.components.ImagePanelStyle;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.view.CardView;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.mage.card.arcane.ManaSymbols;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import mage.game.command.Emblem;
|
import mage.game.command.Emblem;
|
||||||
import mage.game.permanent.PermanentToken;
|
import mage.game.permanent.PermanentToken;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
|
import mage.view.CardView;
|
||||||
import mage.view.EmblemView;
|
import mage.view.EmblemView;
|
||||||
import mage.view.PermanentView;
|
import mage.view.PermanentView;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.mage.card.arcane.ManaSymbols;
|
||||||
import org.mage.plugins.card.images.CardDownloadData;
|
import org.mage.plugins.card.images.CardDownloadData;
|
||||||
|
|
||||||
import static java.lang.Math.min;
|
|
||||||
import static org.mage.plugins.card.images.DownloadPictures.getTokenCardUrls;
|
import static org.mage.plugins.card.images.DownloadPictures.getTokenCardUrls;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,7 +143,6 @@ public class MageBook extends JComponent {
|
||||||
|
|
||||||
int captionHeight = Math.max(30, pageLeft.getHeight()); // caption size = next-prev images
|
int captionHeight = Math.max(30, pageLeft.getHeight()); // caption size = next-prev images
|
||||||
|
|
||||||
|
|
||||||
// Top Panel (left page + (caption / stats) + right page
|
// Top Panel (left page + (caption / stats) + right page
|
||||||
jPanelTop = new JPanel();
|
jPanelTop = new JPanel();
|
||||||
jPanelTop.setLayout(new BorderLayout());
|
jPanelTop.setLayout(new BorderLayout());
|
||||||
|
@ -290,11 +288,9 @@ public class MageBook extends JComponent {
|
||||||
|
|
||||||
public int showTokens() {
|
public int showTokens() {
|
||||||
jLayeredPane.removeAll();
|
jLayeredPane.removeAll();
|
||||||
|
|
||||||
List<Token> tokens = getTokens(currentPage, currentSet);
|
List<Token> tokens = getTokens(currentPage, currentSet);
|
||||||
int size = tokens.size();
|
|
||||||
|
|
||||||
if (tokens != null && tokens.size() > 0) {
|
if (tokens != null && tokens.size() > 0) {
|
||||||
|
int size = tokens.size();
|
||||||
Rectangle rectangle = new Rectangle();
|
Rectangle rectangle = new Rectangle();
|
||||||
rectangle.translate(OFFSET_X, OFFSET_Y);
|
rectangle.translate(OFFSET_X, OFFSET_Y);
|
||||||
for (int i = 0; i < min(conf.CARDS_PER_PAGE / 2, size); i++) {
|
for (int i = 0; i < min(conf.CARDS_PER_PAGE / 2, size); i++) {
|
||||||
|
@ -322,10 +318,9 @@ public class MageBook extends JComponent {
|
||||||
|
|
||||||
public void showEmblems(int numTokens) {
|
public void showEmblems(int numTokens) {
|
||||||
List<Emblem> emblems = getEmblems(currentPage, currentSet, numTokens);
|
List<Emblem> emblems = getEmblems(currentPage, currentSet, numTokens);
|
||||||
int size = emblems.size();
|
// System.out.println ("Size of origins in " + currentSet + " = " + emblems.size());
|
||||||
System.out.println ("Size of origins in " + currentSet + " = " + emblems.size());
|
|
||||||
|
|
||||||
if (emblems != null && emblems.size() > 0) {
|
if (emblems != null && emblems.size() > 0) {
|
||||||
|
int size = emblems.size();
|
||||||
Rectangle rectangle = new Rectangle();
|
Rectangle rectangle = new Rectangle();
|
||||||
rectangle.translate(OFFSET_X, OFFSET_Y);
|
rectangle.translate(OFFSET_X, OFFSET_Y);
|
||||||
// calculate the x offset of the second (right) page
|
// calculate the x offset of the second (right) page
|
||||||
|
@ -389,7 +384,6 @@ public class MageBook extends JComponent {
|
||||||
label.setBounds(rectangle.x + dx, rectangle.y + cardDimensions.frameHeight + 7, 110, 30);
|
label.setBounds(rectangle.x + dx, rectangle.y + cardDimensions.frameHeight + 7, 110, 30);
|
||||||
jLayeredPane.add(label);
|
jLayeredPane.add(label);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// card number label
|
// card number label
|
||||||
JLabel cardNumber = new JLabel();
|
JLabel cardNumber = new JLabel();
|
||||||
int dy = -5; // image panel have empty space in bottom (bug?), need to move label up
|
int dy = -5; // image panel have empty space in bottom (bug?), need to move label up
|
||||||
|
@ -436,26 +430,25 @@ public class MageBook extends JComponent {
|
||||||
return cards.subList(start, end);
|
return cards.subList(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCardStats(String setCode, boolean isCardsShow){
|
private void updateCardStats(String setCode, boolean isCardsShow) {
|
||||||
// sets do not have total cards number, it's a workaround
|
// sets do not have total cards number, it's a workaround
|
||||||
|
|
||||||
ExpansionSet set = Sets.findSet(setCode);
|
ExpansionSet set = Sets.findSet(setCode);
|
||||||
if (set != null){
|
if (set != null) {
|
||||||
setCaption.setText(set.getCode() + " - " + set.getName());
|
setCaption.setText(set.getCode() + " - " + set.getName());
|
||||||
}else{
|
} else {
|
||||||
setCaption.setText("ERROR");
|
setCaption.setText("ERROR");
|
||||||
setInfo.setText("ERROR");
|
setInfo.setText("ERROR");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isCardsShow){
|
if (!isCardsShow) {
|
||||||
// tokens or emblems, stats not need
|
// tokens or emblems, stats not need
|
||||||
setInfo.setText("");
|
setInfo.setText("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// cards stats
|
// cards stats
|
||||||
|
|
||||||
int startNumber = 9999;
|
int startNumber = 9999;
|
||||||
int endNumber = 0;
|
int endNumber = 0;
|
||||||
|
|
||||||
|
@ -463,11 +456,11 @@ public class MageBook extends JComponent {
|
||||||
|
|
||||||
// first run for numbers list
|
// first run for numbers list
|
||||||
LinkedList<Integer> haveNumbers = new LinkedList<>();
|
LinkedList<Integer> haveNumbers = new LinkedList<>();
|
||||||
for (ExpansionSet.SetCardInfo card: cards){
|
for (ExpansionSet.SetCardInfo card : cards) {
|
||||||
int cardNumber = card.getCardNumberAsInt();
|
int cardNumber = card.getCardNumberAsInt();
|
||||||
|
|
||||||
// skip xmage special numbers for cards (TODO: replace full art cards numbers from 180+20 to 180b, 180c and vice versa like scryfall)
|
// skip xmage special numbers for cards (TODO: replace full art cards numbers from 180+20 to 180b, 180c and vice versa like scryfall)
|
||||||
if(cardNumber > 500){
|
if (cardNumber > 500) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,9 +472,9 @@ public class MageBook extends JComponent {
|
||||||
// second run for empty numbers
|
// second run for empty numbers
|
||||||
int countHave = haveNumbers.size();
|
int countHave = haveNumbers.size();
|
||||||
int countNotHave = 0;
|
int countNotHave = 0;
|
||||||
if (cards.size() > 0){
|
if (cards.size() > 0) {
|
||||||
for(int i = startNumber; i <= endNumber; i++){
|
for (int i = startNumber; i <= endNumber; i++) {
|
||||||
if(!haveNumbers.contains(i)){
|
if (!haveNumbers.contains(i)) {
|
||||||
countNotHave++;
|
countNotHave++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -491,7 +484,7 @@ public class MageBook extends JComponent {
|
||||||
setInfo.setText(String.format("Have %d cards of %d", countHave, countHave + countNotHave));
|
setInfo.setText(String.format("Have %d cards of %d", countHave, countHave + countNotHave));
|
||||||
if (countNotHave > 0) {
|
if (countNotHave > 0) {
|
||||||
setInfo.setForeground(new Color(150, 0, 0));
|
setInfo.setForeground(new Color(150, 0, 0));
|
||||||
}else{
|
} else {
|
||||||
setInfo.setForeground(jLayeredPane.getForeground());
|
setInfo.setForeground(jLayeredPane.getForeground());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -520,21 +513,10 @@ public class MageBook extends JComponent {
|
||||||
if (newToken != null && newToken instanceof mage.game.permanent.token.Token) {
|
if (newToken != null && newToken instanceof mage.game.permanent.token.Token) {
|
||||||
((Token) newToken).setExpansionSetCodeForImage(set);
|
((Token) newToken).setExpansionSetCodeForImage(set);
|
||||||
((Token) newToken).setOriginalExpansionSetCode(set);
|
((Token) newToken).setOriginalExpansionSetCode(set);
|
||||||
|
((Token) newToken).setTokenType(token.getType());
|
||||||
tokens.add((Token) newToken);
|
tokens.add((Token) newToken);
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
|
||||||
// Swallow exception
|
|
||||||
} catch (NoSuchMethodException ex) {
|
|
||||||
// Swallow exception
|
|
||||||
} catch (SecurityException ex) {
|
|
||||||
// Swallow exception
|
|
||||||
} catch (InstantiationException ex) {
|
|
||||||
// Swallow exception
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
// Swallow exception
|
|
||||||
} catch (IllegalArgumentException ex) {
|
|
||||||
// Swallow exception
|
|
||||||
} catch (InvocationTargetException ex) {
|
|
||||||
// Swallow exception
|
// Swallow exception
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import mage.constants.SubType;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.mage.plugins.card.images.CardDownloadData;
|
import org.mage.plugins.card.images.CardDownloadData;
|
||||||
import org.mage.plugins.card.images.DownloadPictures;
|
import org.mage.plugins.card.images.DownloadPictures;
|
||||||
|
@ -83,35 +84,6 @@ public enum TokensMtgImageSource implements CardImageSource {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String[] EMBLEMS = {
|
|
||||||
"Ajani",
|
|
||||||
"Arlinn",
|
|
||||||
"Chandra",
|
|
||||||
"Dack",
|
|
||||||
"Daretti",
|
|
||||||
"Dovin",
|
|
||||||
"Domri",
|
|
||||||
"Elspeth",
|
|
||||||
"Garruk",
|
|
||||||
"Gideon",
|
|
||||||
"Huatli",
|
|
||||||
"Jace",
|
|
||||||
"Kiora",
|
|
||||||
"Koth",
|
|
||||||
"Liliana",
|
|
||||||
"Narset",
|
|
||||||
"Nixilis",
|
|
||||||
"Sarkhan",
|
|
||||||
"Sorin",
|
|
||||||
"Tamiyo",
|
|
||||||
"Teferi",
|
|
||||||
"Venser",
|
|
||||||
// Custom Emblems
|
|
||||||
"Yoda",
|
|
||||||
"Obi-Wan Kenobi",
|
|
||||||
"Aurra Sing"
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final Map<String, String> SET_NAMES_REPLACEMENT = new HashMap<String, String>() {
|
private static final Map<String, String> SET_NAMES_REPLACEMENT = new HashMap<String, String>() {
|
||||||
{
|
{
|
||||||
put("con", "CFX");
|
put("con", "CFX");
|
||||||
|
@ -119,6 +91,16 @@ public enum TokensMtgImageSource implements CardImageSource {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private String getEmblemName(String originalName) {
|
||||||
|
|
||||||
|
for (SubType subType : SubType.getPlaneswalkerTypes(true)) {
|
||||||
|
if (originalName.toLowerCase().contains(subType.toString().toLowerCase())) {
|
||||||
|
return subType.getDescription() + " Emblem";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateTokenUrl(CardDownloadData card) throws IOException {
|
public String generateTokenUrl(CardDownloadData card) throws IOException {
|
||||||
String name = card.getName();
|
String name = card.getName();
|
||||||
|
@ -127,12 +109,7 @@ public enum TokensMtgImageSource implements CardImageSource {
|
||||||
|
|
||||||
// handle emblems
|
// handle emblems
|
||||||
if (name.toLowerCase().contains("emblem")) {
|
if (name.toLowerCase().contains("emblem")) {
|
||||||
for (String emblem : EMBLEMS) {
|
name = getEmblemName(name);
|
||||||
if (name.toLowerCase().contains(emblem.toLowerCase())) {
|
|
||||||
name = emblem + " Emblem";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// we should replace some set names
|
// we should replace some set names
|
||||||
|
@ -152,20 +129,16 @@ public enum TokensMtgImageSource implements CardImageSource {
|
||||||
String key = set + "/" + name;
|
String key = set + "/" + name;
|
||||||
List<TokenData> list = tokensData.get(key);
|
List<TokenData> list = tokensData.get(key);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
logger.info("Could not find data for token " + name + ", set " + set + ".");
|
logger.warn("Could not find data for token " + name + ", set " + set + ".");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenData tokenData;
|
TokenData tokenData;
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
if (list.size() > 1) {
|
|
||||||
logger.info("Multiple images were found for token " + name + ", set " + set + '.');
|
|
||||||
}
|
|
||||||
logger.info("Token found: " + name + ", set " + set + '.');
|
|
||||||
tokenData = list.get(0);
|
tokenData = list.get(0);
|
||||||
} else {
|
} else {
|
||||||
if (type > list.size()) {
|
if (type > list.size()) {
|
||||||
logger.warn("Not enough images for token with type " + type + ", name " + name + ", set " + set + '.');
|
logger.warn("Not enough images variants for token with type number " + type + ", name " + name + ", set " + set + '.');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
tokenData = list.get(card.getType() - 1);
|
tokenData = list.get(card.getType() - 1);
|
||||||
|
@ -177,6 +150,57 @@ public enum TokensMtgImageSource implements CardImageSource {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTotalImages() {
|
||||||
|
return getTokenImages();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTokenImages() {
|
||||||
|
try {
|
||||||
|
getTokensData();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
logger.error(getSourceName() + ": Loading available data failed. " + ex.getMessage());
|
||||||
|
}
|
||||||
|
return tokensData.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTokenSource() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doPause(String httpImageUrl) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> getSupportedSets() {
|
||||||
|
ArrayList<String> supportedSetsCopy = new ArrayList<>();
|
||||||
|
supportedSetsCopy.addAll(supportedSets);
|
||||||
|
return supportedSetsCopy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isImageProvided(String setCode, String cardName) {
|
||||||
|
String searchName = cardName;
|
||||||
|
if (cardName.toLowerCase().contains("emblem")) {
|
||||||
|
searchName = getEmblemName(cardName);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
getTokensData();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
java.util.logging.Logger.getLogger(TokensMtgImageSource.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
String key = setCode + "/" + searchName;
|
||||||
|
return (tokensData.containsKey(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSetSupportedComplete(String setCode) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private HashMap<String, ArrayList<TokenData>> getTokensData() throws IOException {
|
private HashMap<String, ArrayList<TokenData>> getTokensData() throws IOException {
|
||||||
synchronized (tokensDataSync) {
|
synchronized (tokensDataSync) {
|
||||||
if (tokensData == null) {
|
if (tokensData == null) {
|
||||||
|
@ -193,7 +217,7 @@ public enum TokensMtgImageSource implements CardImageSource {
|
||||||
list = new ArrayList<>();
|
list = new ArrayList<>();
|
||||||
tokensData.put(key, list);
|
tokensData.put(key, list);
|
||||||
supportedSets.add(tokenData.getExpansionSetCode());
|
supportedSets.add(tokenData.getExpansionSetCode());
|
||||||
logger.info("Added key: " + key);
|
logger.debug("Added key: " + key);
|
||||||
}
|
}
|
||||||
list.add(tokenData);
|
list.add(tokenData);
|
||||||
}
|
}
|
||||||
|
@ -207,6 +231,7 @@ public enum TokensMtgImageSource implements CardImageSource {
|
||||||
try (InputStream inputStream = url.openStream()) {
|
try (InputStream inputStream = url.openStream()) {
|
||||||
List<TokenData> siteTokensData = parseTokensData(inputStream);
|
List<TokenData> siteTokensData = parseTokensData(inputStream);
|
||||||
for (TokenData siteData : siteTokensData) {
|
for (TokenData siteData : siteTokensData) {
|
||||||
|
// logger.info("TOK: " + siteData.getExpansionSetCode() + "/" + siteData.getName());
|
||||||
String key = siteData.getExpansionSetCode() + "/" + siteData.getName();
|
String key = siteData.getExpansionSetCode() + "/" + siteData.getName();
|
||||||
supportedSets.add(siteData.getExpansionSetCode());
|
supportedSets.add(siteData.getExpansionSetCode());
|
||||||
ArrayList<TokenData> list = tokensData.get(key);
|
ArrayList<TokenData> list = tokensData.get(key);
|
||||||
|
@ -267,7 +292,7 @@ public enum TokensMtgImageSource implements CardImageSource {
|
||||||
}
|
}
|
||||||
String[] split = line.split(",");
|
String[] split = line.split(",");
|
||||||
// replace special comma for cards like 'Ashaya‚ the Awoken World'
|
// replace special comma for cards like 'Ashaya‚ the Awoken World'
|
||||||
String name = split[0].replace('‚', ',');
|
String name = split[0].replace('‚', ',').replace("‚", ",");
|
||||||
String number = split[1];
|
String number = split[1];
|
||||||
TokenData token = new TokenData(name, number, set);
|
TokenData token = new TokenData(name, number, set);
|
||||||
newTokensData.add(token);
|
newTokensData.add(token);
|
||||||
|
@ -305,51 +330,4 @@ public enum TokensMtgImageSource implements CardImageSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTotalImages() {
|
|
||||||
return getTokenImages();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTokenImages() {
|
|
||||||
try {
|
|
||||||
getTokensData();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
logger.error(getSourceName() + ": Loading available data failed. " + ex.getMessage());
|
|
||||||
}
|
|
||||||
return tokensData.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isTokenSource() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doPause(String httpImageUrl) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArrayList<String> getSupportedSets() {
|
|
||||||
ArrayList<String> supportedSetsCopy = new ArrayList<>();
|
|
||||||
supportedSetsCopy.addAll(supportedSets);
|
|
||||||
return supportedSetsCopy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isImageProvided(String setCode, String cardName) {
|
|
||||||
try {
|
|
||||||
getTokensData();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
java.util.logging.Logger.getLogger(TokensMtgImageSource.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
String key = setCode + "/" + cardName;
|
|
||||||
return (tokensData.containsKey(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSetSupportedComplete(String setCode) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,7 +352,7 @@ public enum WizardCardsImageSource implements CardImageSource {
|
||||||
setsAliases.put("EVG", "Duel Decks: Elves vs. Goblins");
|
setsAliases.put("EVG", "Duel Decks: Elves vs. Goblins");
|
||||||
setsAliases.put("EXO", "Exodus");
|
setsAliases.put("EXO", "Exodus");
|
||||||
setsAliases.put("FEM", "Fallen Empires");
|
setsAliases.put("FEM", "Fallen Empires");
|
||||||
setsAliases.put("FNMP", "Friday Night Magic");
|
// setsAliases.put("FNMP", "Friday Night Magic");
|
||||||
setsAliases.put("FRF", "Fate Reforged");
|
setsAliases.put("FRF", "Fate Reforged");
|
||||||
setsAliases.put("FUT", "Future Sight");
|
setsAliases.put("FUT", "Future Sight");
|
||||||
setsAliases.put("GPT", "Guildpact");
|
setsAliases.put("GPT", "Guildpact");
|
||||||
|
|
|
@ -2,24 +2,17 @@ package org.mage.plugins.card.images;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ItemEvent;
|
import java.awt.event.ItemEvent;
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.nio.file.AccessDeniedException;
|
import java.nio.file.AccessDeniedException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.imageio.IIOImage;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.imageio.ImageWriteParam;
|
|
||||||
import javax.imageio.ImageWriter;
|
|
||||||
import javax.imageio.stream.FileImageOutputStream;
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import mage.cards.ExpansionSet;
|
import mage.cards.ExpansionSet;
|
||||||
import mage.cards.Sets;
|
import mage.cards.Sets;
|
||||||
|
@ -38,13 +31,11 @@ import org.apache.log4j.Logger;
|
||||||
import org.mage.plugins.card.dl.sources.*;
|
import org.mage.plugins.card.dl.sources.*;
|
||||||
import org.mage.plugins.card.properties.SettingsManager;
|
import org.mage.plugins.card.properties.SettingsManager;
|
||||||
import org.mage.plugins.card.utils.CardImageUtils;
|
import org.mage.plugins.card.utils.CardImageUtils;
|
||||||
|
|
||||||
import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
|
import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
|
||||||
|
|
||||||
public class DownloadPictures extends DefaultBoundedRangeModel implements Runnable {
|
public class DownloadPictures extends DefaultBoundedRangeModel implements Runnable {
|
||||||
|
|
||||||
// don't forget to remove new sets from ignore.urls to download (propeties file in resources)
|
// don't forget to remove new sets from ignore.urls to download (propeties file in resources)
|
||||||
|
|
||||||
private static DownloadPictures instance;
|
private static DownloadPictures instance;
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(DownloadPictures.class);
|
private static final Logger logger = Logger.getLogger(DownloadPictures.class);
|
||||||
|
@ -300,7 +291,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
if (expansionSet != null) {
|
if (expansionSet != null) {
|
||||||
setNames.add(expansionSet.getName());
|
setNames.add(expansionSet.getName());
|
||||||
} else {
|
} else {
|
||||||
logger.error(cardImageSource.getSourceName() + ": Expansion set for code " + setCode + " not found!");
|
logger.warn("Source: " + cardImageSource.getSourceName() + ": Expansion set for code " + setCode + " not found in xmage sets!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +343,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
if (cardImageSource.isTokenSource() && cardImageSource.isImageProvided(data.getSet(), data.getName())) {
|
if (cardImageSource.isTokenSource() && cardImageSource.isImageProvided(data.getSet(), data.getName())) {
|
||||||
numberTokenImagesAvailable++;
|
numberTokenImagesAvailable++;
|
||||||
cardsToDownload.add(data);
|
cardsToDownload.add(data);
|
||||||
}else{
|
} else {
|
||||||
//logger.warn("Source do not support token (set " + data.getSet() + ", token " + data.getName() + ")");
|
//logger.warn("Source do not support token (set " + data.getSet() + ", token " + data.getName() + ")");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -433,7 +424,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
}
|
}
|
||||||
|
|
||||||
CardInfo secondSideCard = CardRepository.instance.findCard(card.getSecondSideName());
|
CardInfo secondSideCard = CardRepository.instance.findCard(card.getSecondSideName());
|
||||||
if (secondSideCard == null){
|
if (secondSideCard == null) {
|
||||||
throw new IllegalStateException("Can''t find second side card in database: " + card.getSecondSideName());
|
throw new IllegalStateException("Can''t find second side card in database: " + card.getSecondSideName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,6 +464,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
logger.debug(card.getName() + " (is_token=" + card.isToken() + "). Image is here:" + file.getAbsolutePath() + " (exists=" + file.exists() + ')');
|
logger.debug(card.getName() + " (is_token=" + card.isToken() + "). Image is here:" + file.getAbsolutePath() + " (exists=" + file.exists() + ')');
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
logger.debug("Missing: " + file.getAbsolutePath());
|
logger.debug("Missing: " + file.getAbsolutePath());
|
||||||
|
// logger.info("Missing image: " + (card.isToken() ? "TOKEN " : "CARD ") + card.getSet() + "/" + card.getName() + " type: " + card.getType());
|
||||||
cardsToDownload.add(card);
|
cardsToDownload.add(card);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -517,6 +509,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
CardDownloadData card = new CardDownloadData(params[3], set, "0", false, type, "", "", true);
|
CardDownloadData card = new CardDownloadData(params[3], set, "0", false, type, "", "", true);
|
||||||
card.setTokenClassName(tokenClassName);
|
card.setTokenClassName(tokenClassName);
|
||||||
list.add(card);
|
list.add(card);
|
||||||
|
// logger.debug("Token: " + set + "/" + card.getName() + " type: " + type);
|
||||||
} else if (params[1].toLowerCase().equals("generate") && params[2].startsWith("EMBLEM:")) {
|
} else if (params[1].toLowerCase().equals("generate") && params[2].startsWith("EMBLEM:")) {
|
||||||
String set = params[2].substring(7);
|
String set = params[2].substring(7);
|
||||||
CardDownloadData card = new CardDownloadData("Emblem " + params[3], set, "0", false, type, "", "", true, fileName);
|
CardDownloadData card = new CardDownloadData("Emblem " + params[3], set, "0", false, type, "", "", true, fileName);
|
||||||
|
@ -696,7 +689,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
TFile destFile;
|
TFile destFile;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (card == null){
|
if (card == null) {
|
||||||
synchronized (sync) {
|
synchronized (sync) {
|
||||||
update(cardIndex + 1, count);
|
update(cardIndex + 1, count);
|
||||||
}
|
}
|
||||||
|
@ -705,29 +698,31 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
|
|
||||||
// gen temp file (download to images folder)
|
// gen temp file (download to images folder)
|
||||||
String tempPath = getImagesDir() + File.separator + "downloading" + File.separator;
|
String tempPath = getImagesDir() + File.separator + "downloading" + File.separator;
|
||||||
if(useSpecifiedPaths){
|
if (useSpecifiedPaths) {
|
||||||
fileTempImage = new TFile(tempPath + actualFilename + "-" + card.hashCode() + ".jpg");
|
fileTempImage = new TFile(tempPath + actualFilename + "-" + card.hashCode() + ".jpg");
|
||||||
}else{
|
} else {
|
||||||
fileTempImage = new TFile(tempPath + CardImageUtils.prepareCardNameForFile(card.getName()) + "-" + card.hashCode() + ".jpg");
|
fileTempImage = new TFile(tempPath + CardImageUtils.prepareCardNameForFile(card.getName()) + "-" + card.hashCode() + ".jpg");
|
||||||
}
|
}
|
||||||
if(!fileTempImage.getParentFile().exists()){
|
TFile parentFile = fileTempImage.getParentFile();
|
||||||
fileTempImage.getParentFile().mkdirs();
|
if (parentFile != null) {
|
||||||
|
if (!parentFile.exists()) {
|
||||||
|
parentFile.mkdirs();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// gen dest file name
|
// gen dest file name
|
||||||
if(useSpecifiedPaths)
|
if (useSpecifiedPaths) {
|
||||||
{
|
if (card.isToken()) {
|
||||||
if(card.isToken()){
|
|
||||||
destFile = new TFile(CardImageUtils.buildImagePathToSet(card) + actualFilename + ".jpg");
|
destFile = new TFile(CardImageUtils.buildImagePathToSet(card) + actualFilename + ".jpg");
|
||||||
}else{
|
} else {
|
||||||
destFile = new TFile(CardImageUtils.buildImagePathToTokens() + actualFilename + ".jpg");
|
destFile = new TFile(CardImageUtils.buildImagePathToTokens() + actualFilename + ".jpg");
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
destFile = new TFile(CardImageUtils.buildImagePathToCard(card));
|
destFile = new TFile(CardImageUtils.buildImagePathToCard(card));
|
||||||
}
|
}
|
||||||
|
|
||||||
// FILE already exists (in zip or in dir)
|
// FILE already exists (in zip or in dir)
|
||||||
if (destFile.exists()){
|
if (destFile.exists()) {
|
||||||
synchronized (sync) {
|
synchronized (sync) {
|
||||||
update(cardIndex + 1, count);
|
update(cardIndex + 1, count);
|
||||||
}
|
}
|
||||||
|
@ -776,8 +771,6 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
}
|
}
|
||||||
// WTF end?!
|
// WTF end?!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// START to download
|
// START to download
|
||||||
cardImageSource.doPause(url.getPath());
|
cardImageSource.doPause(url.getPath());
|
||||||
URLConnection httpConn = url.openConnection(p);
|
URLConnection httpConn = url.openConnection(p);
|
||||||
|
@ -785,7 +778,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
httpConn.connect();
|
httpConn.connect();
|
||||||
int responseCode = ((HttpURLConnection) httpConn).getResponseCode();
|
int responseCode = ((HttpURLConnection) httpConn).getResponseCode();
|
||||||
|
|
||||||
if (responseCode == 200){
|
if (responseCode == 200) {
|
||||||
// download OK
|
// download OK
|
||||||
// save data to temp
|
// save data to temp
|
||||||
BufferedOutputStream out;
|
BufferedOutputStream out;
|
||||||
|
@ -803,18 +796,18 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
// stop download, save current state and exit
|
// stop download, save current state and exit
|
||||||
TFile archive = destFile.getTopLevelArchive();
|
TFile archive = destFile.getTopLevelArchive();
|
||||||
///* not need to unmout/close - it's auto action
|
///* not need to unmout/close - it's auto action
|
||||||
if (archive != null && archive.exists()){
|
if (archive != null && archive.exists()) {
|
||||||
logger.info("User canceled download. Closing archive file: " + destFile.toString());
|
logger.info("User canceled download. Closing archive file: " + destFile.toString());
|
||||||
try {
|
try {
|
||||||
TVFS.umount(archive);
|
TVFS.umount(archive);
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Can't close archive file: " + e.getMessage(), e);
|
logger.error("Can't close archive file: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}//*/
|
}//*/
|
||||||
try {
|
try {
|
||||||
TFile.rm(fileTempImage);
|
TFile.rm(fileTempImage);
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Can't delete temp file: " + e.getMessage(), e);
|
logger.error("Can't delete temp file: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -827,21 +820,20 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
// TODO: add two faces card correction? (WTF)
|
// TODO: add two faces card correction? (WTF)
|
||||||
|
|
||||||
// SAVE final data
|
// SAVE final data
|
||||||
if (fileTempImage.exists()) {
|
if (fileTempImage.exists()) {
|
||||||
if (!destFile.getParentFile().exists()){
|
if (!destFile.getParentFile().exists()) {
|
||||||
destFile.getParentFile().mkdirs();
|
destFile.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
new TFile(fileTempImage).cp_rp(destFile);
|
new TFile(fileTempImage).cp_rp(destFile);
|
||||||
try {
|
try {
|
||||||
TFile.rm(fileTempImage);
|
TFile.rm(fileTempImage);
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Can't delete temp file: " + e.getMessage(), e);
|
logger.error("Can't delete temp file: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
// download ERROR
|
// download ERROR
|
||||||
logger.warn("Image download for " + card.getName()
|
logger.warn("Image download for " + card.getName()
|
||||||
+ (!card.getDownloadName().equals(card.getName()) ? " downloadname: " + card.getDownloadName() : "")
|
+ (!card.getDownloadName().equals(card.getName()) ? " downloadname: " + card.getDownloadName() : "")
|
||||||
|
@ -929,7 +921,6 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
} catch (AccessDeniedException e) {
|
} catch (AccessDeniedException e) {
|
||||||
logger.error("Can't access to files: " + card.getName() + "(" + card.getSet() + "). Try rebooting your system to remove the file lock.");
|
logger.error("Can't access to files: " + card.getName() + "(" + card.getSet() + "). Try rebooting your system to remove the file lock.");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -942,25 +933,25 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeImageToFile(BufferedImage image, TFile file) throws IOException {
|
// private void writeImageToFile(BufferedImage image, TFile file) throws IOException {
|
||||||
Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
|
// Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
|
||||||
|
//
|
||||||
ImageWriter writer = (ImageWriter) iter.next();
|
// ImageWriter writer = (ImageWriter) iter.next();
|
||||||
ImageWriteParam iwp = writer.getDefaultWriteParam();
|
// ImageWriteParam iwp = writer.getDefaultWriteParam();
|
||||||
iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
|
// iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
|
||||||
iwp.setCompressionQuality(0.96f);
|
// iwp.setCompressionQuality(0.96f);
|
||||||
|
//
|
||||||
File tempFile = new File(getImagesDir() + File.separator + image.hashCode() + file.getName());
|
// File tempFile = new File(getImagesDir() + File.separator + image.hashCode() + file.getName());
|
||||||
FileImageOutputStream output = new FileImageOutputStream(tempFile);
|
// FileImageOutputStream output = new FileImageOutputStream(tempFile);
|
||||||
writer.setOutput(output);
|
// writer.setOutput(output);
|
||||||
IIOImage image2 = new IIOImage(image, null, null);
|
// IIOImage image2 = new IIOImage(image, null, null);
|
||||||
writer.write(null, image2, iwp);
|
// writer.write(null, image2, iwp);
|
||||||
writer.dispose();
|
// writer.dispose();
|
||||||
output.close();
|
// output.close();
|
||||||
|
//
|
||||||
new TFile(tempFile).cp_rp(file);
|
// new TFile(tempFile).cp_rp(file);
|
||||||
tempFile.delete();
|
// tempFile.delete();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update(int card, int count) {
|
private void update(int card, int count) {
|
||||||
|
|
|
@ -56,8 +56,7 @@ public final class CardImageUtils {
|
||||||
*/
|
*/
|
||||||
public static String generateFullTokenImagePath(CardDownloadData card) {
|
public static String generateFullTokenImagePath(CardDownloadData card) {
|
||||||
if (card.isToken()) {
|
if (card.isToken()) {
|
||||||
String filePath = getTokenImagePath(card);
|
return getTokenImagePath(card);
|
||||||
return filePath;
|
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -67,23 +66,29 @@ public final class CardImageUtils {
|
||||||
|
|
||||||
TFile file = new TFile(filename);
|
TFile file = new TFile(filename);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
filename = generateTokenDescriptorImagePath(card);
|
String tokenDescriptorfilename = generateTokenDescriptorImagePath(card);
|
||||||
}
|
if (!tokenDescriptorfilename.isEmpty()) {
|
||||||
|
|
||||||
file = new TFile(filename);
|
file = new TFile(filename);
|
||||||
if (!file.exists()) {
|
if (file.exists()) {
|
||||||
CardDownloadData updated = new CardDownloadData(card);
|
return tokenDescriptorfilename;
|
||||||
updated.setName(card.getName() + " 1");
|
}
|
||||||
filename = buildImagePathToCard(updated);
|
|
||||||
file = new TFile(filename);
|
|
||||||
if (!file.exists()) {
|
|
||||||
updated = new CardDownloadData(card);
|
|
||||||
updated.setName(card.getName() + " 2");
|
|
||||||
filename = buildImagePathToCard(updated);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return filename;
|
return filename;
|
||||||
|
|
||||||
|
// makes no longer sense
|
||||||
|
// file = new TFile(filename);
|
||||||
|
// if (!file.exists()) {
|
||||||
|
// CardDownloadData updated = new CardDownloadData(card);
|
||||||
|
// updated.setName(card.getName() + " 1");
|
||||||
|
// filename = buildImagePathToCard(updated);
|
||||||
|
// file = new TFile(filename);
|
||||||
|
// if (!file.exists()) {
|
||||||
|
// updated = new CardDownloadData(card);
|
||||||
|
// updated.setName(card.getName() + " 2");
|
||||||
|
// filename = buildImagePathToCard(updated);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String searchForCardImage(CardDownloadData card) {
|
private static String searchForCardImage(CardDownloadData card) {
|
||||||
|
@ -208,7 +213,7 @@ public final class CardImageUtils {
|
||||||
if (card.getUsesVariousArt()) {
|
if (card.getUsesVariousArt()) {
|
||||||
finalFileName = cardName + '.' + card.getCollectorId() + ".full.jpg";
|
finalFileName = cardName + '.' + card.getCollectorId() + ".full.jpg";
|
||||||
} else {
|
} else {
|
||||||
if (card.getUsesVariousArt()){
|
if (card.getUsesVariousArt()) {
|
||||||
// only various arts can be same name, but different postfixes (a,b,c,d,e)
|
// only various arts can be same name, but different postfixes (a,b,c,d,e)
|
||||||
int len = card.getCollectorId().length();
|
int len = card.getCollectorId().length();
|
||||||
if (Character.isLetter(card.getCollectorId().charAt(len - 1))) {
|
if (Character.isLetter(card.getCollectorId().charAt(len - 1))) {
|
||||||
|
|
|
@ -45,10 +45,10 @@
|
||||||
#|Generate|TOK:PTC|Wolf||
|
#|Generate|TOK:PTC|Wolf||
|
||||||
#|Generate|TOK:PTC|Wurm||
|
#|Generate|TOK:PTC|Wurm||
|
||||||
#|Generate|TOK:WMCQ|Angel||
|
#|Generate|TOK:WMCQ|Angel||
|
||||||
|Generate|EMBLEM!:AKH|Emblem Gideon|||GideonOfTheTrialsEmblem|
|
|
||||||
|Generate|EMBLEM!:BFZ|Emblem Gideon|||GideonAllyOfZendikarEmblem|
|
|Generate|EMBLEM!:BFZ|Emblem Gideon|||GideonAllyOfZendikarEmblem|
|
||||||
|Generate|EMBLEM!:BFZ|Emblem Kiora|||KioraMasterOfTheDepthsEmblem|
|
|Generate|EMBLEM!:BFZ|Emblem Kiora|||KioraMasterOfTheDepthsEmblem|
|
||||||
|Generate|EMBLEM!:BFZ|Emblem Nixilis|||ObNixilisReignitedEmblem|
|
|Generate|EMBLEM!:BFZ|Emblem Nixilis|||ObNixilisReignitedEmblem|
|
||||||
|
|Generate|EMBLEM!:AKH|Emblem Gideon|||GideonOfTheTrialsEmblem|
|
||||||
|Generate|EMBLEM!:C14|Emblem Daretti|||DarettiScrapSavantEmblem|
|
|Generate|EMBLEM!:C14|Emblem Daretti|||DarettiScrapSavantEmblem|
|
||||||
|Generate|EMBLEM!:C14|Emblem Daretti||Emblem Daretti|DarettiScrapSavantEmblem|
|
|Generate|EMBLEM!:C14|Emblem Daretti||Emblem Daretti|DarettiScrapSavantEmblem|
|
||||||
|Generate|EMBLEM!:C14|Emblem Nixilis|||ObNixilisOfTheBlackOathEmblem|
|
|Generate|EMBLEM!:C14|Emblem Nixilis|||ObNixilisOfTheBlackOathEmblem|
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
|Generate|EMBLEM!:ORI|Emblem Liliana|||LilianaDefiantNecromancerEmblem|
|
|Generate|EMBLEM!:ORI|Emblem Liliana|||LilianaDefiantNecromancerEmblem|
|
||||||
|Generate|EMBLEM!:SOI|Emblem Arlinn|||ArlinnEmbracedByTheMoonEmblem|
|
|Generate|EMBLEM!:SOI|Emblem Arlinn|||ArlinnEmbracedByTheMoonEmblem|
|
||||||
|Generate|EMBLEM!:SOI|Emblem Jace|||JaceUnravelerOfSecretsEmblem|
|
|Generate|EMBLEM!:SOI|Emblem Jace|||JaceUnravelerOfSecretsEmblem|
|
||||||
|Generate|EMBLEM-:THS|Elspeth, Suns Champion||Emblem Elspeth|ElspethSunsChampionEmblem|
|
|Generate|EMBLEM:THS|Elspeth, Suns Champion||Emblem Elspeth|ElspethSunsChampionEmblem|
|
||||||
|Generate|EMBLEM:AVR|Tamiyo, the Moon Sage||Emblem Tamiyo|TamiyoTheMoonSageEmblem|
|
|Generate|EMBLEM:AVR|Tamiyo, the Moon Sage||Emblem Tamiyo|TamiyoTheMoonSageEmblem|
|
||||||
|Generate|EMBLEM:BNG|Kiora, the Crashing Wave||Emblem Kiora|KioraEmblem|
|
|Generate|EMBLEM:BNG|Kiora, the Crashing Wave||Emblem Kiora|KioraEmblem|
|
||||||
|Generate|EMBLEM:DDI|Koth of the Hammer||Emblem Koth|KothOfTheHammerEmblem|
|
|Generate|EMBLEM:DDI|Koth of the Hammer||Emblem Koth|KothOfTheHammerEmblem|
|
||||||
|
@ -484,8 +484,8 @@
|
||||||
|Generate|TOK:DKA|Zombie|||ZombieToken|
|
|Generate|TOK:DKA|Zombie|||ZombieToken|
|
||||||
|Generate|TOK:DRB|Saproling|||SaprolingToken|
|
|Generate|TOK:DRB|Saproling|||SaprolingToken|
|
||||||
|Generate|TOK:DST|Beast|||BeastToken|
|
|Generate|TOK:DST|Beast|||BeastToken|
|
||||||
|Generate|TOK:DST|Elemental|||WandOfTheElementsFirstToken|
|
|Generate|TOK:DST|Elemental|1||WandOfTheElementsFirstToken|
|
||||||
|Generate|TOK:DST|Elemental|||WandOfTheElementsSecondToken|
|
|Generate|TOK:DST|Elemental|2||WandOfTheElementsSecondToken|
|
||||||
|Generate|TOK:DST|InsectWirefly|||WireflyToken|
|
|Generate|TOK:DST|InsectWirefly|||WireflyToken|
|
||||||
|Generate|TOK:DST|Insect|||InsectToken|
|
|Generate|TOK:DST|Insect|||InsectToken|
|
||||||
|Generate|TOK:DST|Myr|||MyrToken|
|
|Generate|TOK:DST|Myr|||MyrToken|
|
||||||
|
@ -731,7 +731,7 @@
|
||||||
|Generate|TOK:M15|Beast|2||GarrukApexPredatorBeastToken|
|
|Generate|TOK:M15|Beast|2||GarrukApexPredatorBeastToken|
|
||||||
|Generate|TOK:M15|Dragon|||BroodKeeperDragonToken|
|
|Generate|TOK:M15|Dragon|||BroodKeeperDragonToken|
|
||||||
|Generate|TOK:M15|Goblin|1||GoblinTokenWithHaste|
|
|Generate|TOK:M15|Goblin|1||GoblinTokenWithHaste|
|
||||||
|Generate|TOK:M15|Goblin|2||GoblinToken|
|
# |Generate|TOK:M15|Goblin|2||GoblinToken| #does not exist
|
||||||
|Generate|TOK:M15|Insect|||InsectToken|
|
|Generate|TOK:M15|Insect|||InsectToken|
|
||||||
|Generate|TOK:M15|Land Mine|||LandMineToken|
|
|Generate|TOK:M15|Land Mine|||LandMineToken|
|
||||||
|Generate|TOK:M15|Sliver|||SliverToken|
|
|Generate|TOK:M15|Sliver|||SliverToken|
|
||||||
|
@ -1000,8 +1000,7 @@
|
||||||
|Generate|TOK:SOM|Cat|||CatToken|
|
|Generate|TOK:SOM|Cat|||CatToken|
|
||||||
|Generate|TOK:SOM|Goblin|||GoblinToken|
|
|Generate|TOK:SOM|Goblin|||GoblinToken|
|
||||||
|Generate|TOK:SOM|Golem|||GolemToken|
|
|Generate|TOK:SOM|Golem|||GolemToken|
|
||||||
|Generate|TOK:SOM|Insect|1||InsectToken|
|
|Generate|TOK:SOM|Insect|||InsectInfectToken|
|
||||||
|Generate|TOK:SOM|Insect|2||InsectInfectToken|
|
|
||||||
|Generate|TOK:SOM|Myr|||MyrToken|
|
|Generate|TOK:SOM|Myr|||MyrToken|
|
||||||
|Generate|TOK:SOM|Soldier|||SoldierToken|
|
|Generate|TOK:SOM|Soldier|||SoldierToken|
|
||||||
|Generate|TOK:SOM|Wolf|||WolfToken|
|
|Generate|TOK:SOM|Wolf|||WolfToken|
|
||||||
|
@ -1068,7 +1067,7 @@
|
||||||
|Generate|TOK:USG|Minion|||MinionToken|
|
|Generate|TOK:USG|Minion|||MinionToken|
|
||||||
|Generate|TOK:USG|Saproling|||SaprolingToken|
|
|Generate|TOK:USG|Saproling|||SaprolingToken|
|
||||||
|Generate|TOK:UST|Dragon|||DragonTokenGold|
|
|Generate|TOK:UST|Dragon|||DragonTokenGold|
|
||||||
|Generate|TOK:UST|StormCrow|||StormCrowToken|
|
|Generate|TOK:UST|Storm Crow|||StormCrowToken|
|
||||||
|Generate|TOK:V10|Wolf|||WolfToken|
|
|Generate|TOK:V10|Wolf|||WolfToken|
|
||||||
|Generate|TOK:V11|Faerie Rogue|||OonaQueenFaerieToken|
|
|Generate|TOK:V11|Faerie Rogue|||OonaQueenFaerieToken|
|
||||||
|Generate|TOK:V12|Spirit|||SpiritToken|
|
|Generate|TOK:V12|Spirit|||SpiritToken|
|
||||||
|
|
|
@ -59,9 +59,13 @@ public class WandOfTheElements extends CardImpl {
|
||||||
|
|
||||||
public WandOfTheElements(UUID ownerId, CardSetInfo setInfo) {
|
public WandOfTheElements(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
|
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
|
||||||
|
|
||||||
|
// {T}, Sacrifice an Island: Create a 2/2 blue Elemental creature token with flying.
|
||||||
Ability firstAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new WandOfTheElementsFirstToken()), new TapSourceCost());
|
Ability firstAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new WandOfTheElementsFirstToken()), new TapSourceCost());
|
||||||
firstAbility.addCost(new SacrificeTargetCost(new TargetControlledPermanent(islandFilter)));
|
firstAbility.addCost(new SacrificeTargetCost(new TargetControlledPermanent(islandFilter)));
|
||||||
this.addAbility(firstAbility);
|
this.addAbility(firstAbility);
|
||||||
|
|
||||||
|
// {T}, Sacrifice a Mountain: Create a 3/3 red Elemental creature token.
|
||||||
Ability secondAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new WandOfTheElementsSecondToken()), new TapSourceCost());
|
Ability secondAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new WandOfTheElementsSecondToken()), new TapSourceCost());
|
||||||
secondAbility.addCost(new SacrificeTargetCost(new TargetControlledPermanent(mountainFilter)));
|
secondAbility.addCost(new SacrificeTargetCost(new TargetControlledPermanent(mountainFilter)));
|
||||||
this.addAbility(secondAbility);
|
this.addAbility(secondAbility);
|
||||||
|
|
|
@ -442,6 +442,16 @@ public enum SubType {
|
||||||
return subTypeSet;
|
return subTypeSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Set<SubType> getPlaneswalkerTypes(boolean withCustomSets) {
|
||||||
|
Set<SubType> subTypes = EnumSet.noneOf(SubType.class);
|
||||||
|
for (SubType subType : values()) {
|
||||||
|
if (subType.getSubTypeSet() == SubTypeSet.PlaneswalkerType && (withCustomSets || !subType.customSet)) {
|
||||||
|
subTypes.add(subType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return subTypes;
|
||||||
|
}
|
||||||
|
|
||||||
public static Set<SubType> getCreatureTypes(boolean customSet) {
|
public static Set<SubType> getCreatureTypes(boolean customSet) {
|
||||||
Set<SubType> subTypes = EnumSet.noneOf(SubType.class);
|
Set<SubType> subTypes = EnumSet.noneOf(SubType.class);
|
||||||
for (SubType s : values()) {
|
for (SubType s : values()) {
|
||||||
|
|
|
@ -47,7 +47,7 @@ import mage.game.events.GameEvent;
|
||||||
public class GideonOfTheTrialsEmblem extends Emblem {
|
public class GideonOfTheTrialsEmblem extends Emblem {
|
||||||
|
|
||||||
public GideonOfTheTrialsEmblem() {
|
public GideonOfTheTrialsEmblem() {
|
||||||
this.setName("Emblem - Gideon of the Trials");
|
this.setName("Emblem - Gideon");
|
||||||
Ability ability = new SimpleStaticAbility(Zone.COMMAND, new GideonOfTheTrialsCantLoseEffect());
|
Ability ability = new SimpleStaticAbility(Zone.COMMAND, new GideonOfTheTrialsCantLoseEffect());
|
||||||
this.getAbilities().add(ability);
|
this.getAbilities().add(ability);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ public class RekindlingPhoenixToken extends Token {
|
||||||
|
|
||||||
public RekindlingPhoenixToken() {
|
public RekindlingPhoenixToken() {
|
||||||
super("Elemental", "0/1 red Elemental creature token with \"At the beginning of your upkeep, sacrifice this creature and return target card named Rekindling Phoenix from your graveyard to the battlefield. It gains haste until end of turn.\"");
|
super("Elemental", "0/1 red Elemental creature token with \"At the beginning of your upkeep, sacrifice this creature and return target card named Rekindling Phoenix from your graveyard to the battlefield. It gains haste until end of turn.\"");
|
||||||
|
setTokenType(1);
|
||||||
cardType.add(CardType.CREATURE);
|
cardType.add(CardType.CREATURE);
|
||||||
subtype.add(SubType.THRULL);
|
subtype.add(SubType.THRULL);
|
||||||
color.setRed(true);
|
color.setRed(true);
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class TilonallisSummonerElementalToken extends Token {
|
||||||
|
|
||||||
public TilonallisSummonerElementalToken() {
|
public TilonallisSummonerElementalToken() {
|
||||||
super("Elemental", "1/1 red Elemental creature tokens");
|
super("Elemental", "1/1 red Elemental creature tokens");
|
||||||
|
setTokenType(2);
|
||||||
cardType.add(CardType.CREATURE);
|
cardType.add(CardType.CREATURE);
|
||||||
subtype.add(SubType.ELEMENTAL);
|
subtype.add(SubType.ELEMENTAL);
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,12 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.game.permanent.token;
|
package mage.game.permanent.token;
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.SubType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -40,6 +40,7 @@ public class WandOfTheElementsFirstToken extends Token {
|
||||||
|
|
||||||
public WandOfTheElementsFirstToken() {
|
public WandOfTheElementsFirstToken() {
|
||||||
super("Elemental", "2/2 blue Elemental creature token with flying");
|
super("Elemental", "2/2 blue Elemental creature token with flying");
|
||||||
|
setTokenType(1);
|
||||||
cardType.add(CardType.CREATURE);
|
cardType.add(CardType.CREATURE);
|
||||||
this.subtype.add(SubType.ELEMENTAL);
|
this.subtype.add(SubType.ELEMENTAL);
|
||||||
this.color.setBlue(true);
|
this.color.setBlue(true);
|
||||||
|
|
|
@ -25,11 +25,11 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.game.permanent.token;
|
package mage.game.permanent.token;
|
||||||
|
|
||||||
|
import mage.MageInt;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.MageInt;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -39,6 +39,7 @@ public class WandOfTheElementsSecondToken extends Token {
|
||||||
|
|
||||||
public WandOfTheElementsSecondToken() {
|
public WandOfTheElementsSecondToken() {
|
||||||
super("Elemental", "3/3 red Elemental creature token");
|
super("Elemental", "3/3 red Elemental creature token");
|
||||||
|
setTokenType(2);
|
||||||
cardType.add(CardType.CREATURE);
|
cardType.add(CardType.CREATURE);
|
||||||
this.subtype.add(SubType.ELEMENTAL);
|
this.subtype.add(SubType.ELEMENTAL);
|
||||||
this.color.setRed(true);
|
this.color.setRed(true);
|
||||||
|
|
Loading…
Reference in a new issue