forked from External/mage
Token refactor
This commit is contained in:
parent
a532368b84
commit
e73e7d8600
20 changed files with 1449 additions and 744 deletions
|
|
@ -146,13 +146,13 @@ public final class CollectionViewerPanel extends JPanel {
|
|||
JLabel label4 = new JLabel("Show cards or tokens:");
|
||||
label3.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
label3.setForeground(Color.white);
|
||||
// spjspj - put back in after reorg of tokens -- jPanel1.add(label4);
|
||||
jPanel1.add(label4);
|
||||
|
||||
JCheckBox cardsOrTokens = new JCheckBox("Display Cards");
|
||||
cardsOrTokens.setSelected(true);
|
||||
cardsOrTokens.setToolTipText("Select to show Cards or Tokens(and emblems) for the chosen set");
|
||||
cardsOrTokens.addActionListener(e -> mageBook.cardsOrTokens(cardsOrTokens.isSelected()));
|
||||
// spjspj - put back in after reorg of tokens -- jPanel1.add(cardsOrTokens);
|
||||
jPanel1.add(cardsOrTokens);
|
||||
|
||||
formats.addActionListener(e -> {
|
||||
if (mageBook != null) {
|
||||
|
|
|
|||
|
|
@ -306,6 +306,7 @@ public class MageBook extends JComponent {
|
|||
}
|
||||
PermanentToken newToken = new PermanentToken(token, null, token.getOriginalExpansionSetCode(), null);
|
||||
PermanentView theToken = new PermanentView(newToken, null, null, null);
|
||||
theToken.setInViewerOnly(true);
|
||||
final MageCard cardImg = Plugins.instance.getMagePermanent(theToken, bigCard, cardDimension, gameId, true);
|
||||
cardImg.setBounds(rectangle);
|
||||
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
|
||||
|
|
@ -339,6 +340,9 @@ public class MageBook extends JComponent {
|
|||
String className = token.getName();
|
||||
className = className.replaceAll("[^a-zA-Z0-9]", "");
|
||||
className = className + "Token";
|
||||
if (token.getTokenClassName() != null && token.getTokenClassName().length() > 0) {
|
||||
className = token.getTokenClassName();
|
||||
}
|
||||
Class<?> c = Class.forName("mage.game.permanent.token." + className);
|
||||
Constructor<?> cons = c.getConstructor();
|
||||
Object newToken = cons.newInstance();
|
||||
|
|
@ -346,19 +350,19 @@ public class MageBook extends JComponent {
|
|||
tokens.add((Token) newToken);
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(MageBook.class.getName()).log(Level.SEVERE, null, ex);
|
||||
// Swallow exception
|
||||
} catch (NoSuchMethodException ex) {
|
||||
java.util.logging.Logger.getLogger(MageBook.class.getName()).log(Level.SEVERE, null, ex);
|
||||
// Swallow exception
|
||||
} catch (SecurityException ex) {
|
||||
java.util.logging.Logger.getLogger(MageBook.class.getName()).log(Level.SEVERE, null, ex);
|
||||
// Swallow exception
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(MageBook.class.getName()).log(Level.SEVERE, null, ex);
|
||||
// Swallow exception
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(MageBook.class.getName()).log(Level.SEVERE, null, ex);
|
||||
// Swallow exception
|
||||
} catch (IllegalArgumentException ex) {
|
||||
java.util.logging.Logger.getLogger(MageBook.class.getName()).log(Level.SEVERE, null, ex);
|
||||
// Swallow exception
|
||||
} catch (InvocationTargetException ex) {
|
||||
java.util.logging.Logger.getLogger(MageBook.class.getName()).log(Level.SEVERE, null, ex);
|
||||
// Swallow exception
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
protected UUID gameId;
|
||||
private TransferData data = new TransferData();
|
||||
|
||||
private final boolean isPermanent;
|
||||
private boolean isPermanent;
|
||||
private boolean hasSickness;
|
||||
private String zone;
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
this.gameId = gameId;
|
||||
|
||||
// Gather info about the card
|
||||
this.isPermanent = this.gameCard instanceof PermanentView;
|
||||
this.isPermanent = this.gameCard instanceof PermanentView && !this.gameCard.inViewerOnly();
|
||||
if (isPermanent) {
|
||||
this.hasSickness = ((PermanentView) this.gameCard).hasSummoningSickness();
|
||||
}
|
||||
|
|
@ -202,6 +202,10 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
updateArtImage();
|
||||
}
|
||||
}
|
||||
|
||||
public void setIsPermanent(boolean isPermanent) {
|
||||
this.isPermanent = isPermanent;
|
||||
}
|
||||
|
||||
public void cleanUp() {
|
||||
if (dayNightButton != null) {
|
||||
|
|
|
|||
|
|
@ -23,22 +23,27 @@ public class CardDownloadData {
|
|||
private boolean flippedSide;
|
||||
private boolean splitCard;
|
||||
private final boolean usesVariousArt;
|
||||
private String tokenClassName;
|
||||
private boolean isType2;
|
||||
|
||||
public CardDownloadData(String name, String set, String collectorId, boolean usesVariousArt, Integer type, String tokenSetCode, String tokenDescriptor) {
|
||||
this(name, set, collectorId, usesVariousArt, type, tokenSetCode, tokenDescriptor, false);
|
||||
this(name, set, collectorId, usesVariousArt, type, tokenSetCode, tokenDescriptor, false, "");
|
||||
}
|
||||
|
||||
public CardDownloadData(String name, String set, String collectorId, boolean usesVariousArt, Integer type, String tokenSetCode, String tokenDescriptor, boolean token) {
|
||||
this(name, set, collectorId, usesVariousArt, type, tokenSetCode, tokenDescriptor, token, false, false);
|
||||
this(name, set, collectorId, usesVariousArt, type, tokenSetCode, tokenDescriptor, token, false, false, "");
|
||||
}
|
||||
|
||||
public CardDownloadData(String name, String set, String collectorId, boolean usesVariousArt, Integer type, String tokenSetCode, String tokenDescriptor, boolean token, String fileName) {
|
||||
this(name, set, collectorId, usesVariousArt, type, tokenSetCode, tokenDescriptor, token, false, false);
|
||||
this(name, set, collectorId, usesVariousArt, type, tokenSetCode, tokenDescriptor, token, false, false, "");
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public CardDownloadData(String name, String set, String collectorId, boolean usesVariousArt, Integer type, String tokenSetCode, String tokenDescriptor, boolean token, boolean twoFacedCard, boolean secondSide) {
|
||||
this(name, set, collectorId, usesVariousArt, type, tokenSetCode, tokenDescriptor, token, false, false, "");
|
||||
}
|
||||
|
||||
public CardDownloadData(String name, String set, String collectorId, boolean usesVariousArt, Integer type, String tokenSetCode, String tokenDescriptor, boolean token, boolean twoFacedCard, boolean secondSide, String tokenClassName) {
|
||||
this.name = name;
|
||||
this.set = set;
|
||||
this.collectorId = collectorId;
|
||||
|
|
@ -49,6 +54,7 @@ public class CardDownloadData {
|
|||
this.secondSide = secondSide;
|
||||
this.tokenSetCode = tokenSetCode;
|
||||
this.tokenDescriptor = tokenDescriptor;
|
||||
this.tokenClassName = tokenClassName;
|
||||
|
||||
if (this.tokenDescriptor == null || this.tokenDescriptor.equalsIgnoreCase("")) {
|
||||
this.tokenDescriptor = lastDitchTokenDescriptor();
|
||||
|
|
@ -66,6 +72,7 @@ public class CardDownloadData {
|
|||
this.usesVariousArt = card.usesVariousArt;
|
||||
this.tokenSetCode = card.tokenSetCode;
|
||||
this.tokenDescriptor = card.tokenDescriptor;
|
||||
this.tokenClassName = tokenClassName;
|
||||
this.fileName = card.fileName;
|
||||
|
||||
}
|
||||
|
|
@ -156,6 +163,14 @@ public class CardDownloadData {
|
|||
public String getTokenDescriptor() {
|
||||
return tokenDescriptor;
|
||||
}
|
||||
|
||||
public void setTokenClassName(String tokenClassName) {
|
||||
this.tokenClassName = tokenClassName;
|
||||
}
|
||||
|
||||
public String getTokenClassName() {
|
||||
return tokenClassName;
|
||||
}
|
||||
|
||||
public void setTokenDescriptor(String tokenDescriptor) {
|
||||
this.tokenDescriptor = tokenDescriptor;
|
||||
|
|
|
|||
|
|
@ -362,22 +362,30 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
if (params.length > 5 && params[5] != null && !params[5].isEmpty()) {
|
||||
fileName = params[5].trim();
|
||||
}
|
||||
String tokenClassName = "";
|
||||
if (params.length > 7 && params[6] != null && !params[6].isEmpty()) {
|
||||
tokenClassName = params[6].trim();
|
||||
}
|
||||
|
||||
if (params[1].toLowerCase().equals("generate") && params[2].startsWith("TOK:")) {
|
||||
String set = params[2].substring(4);
|
||||
CardDownloadData card = new CardDownloadData(params[3], set, "0", false, type, "", "", true);
|
||||
card.setTokenClassName(tokenClassName);
|
||||
list.add(card);
|
||||
} else if (params[1].toLowerCase().equals("generate") && params[2].startsWith("EMBLEM:")) {
|
||||
String set = params[2].substring(7);
|
||||
CardDownloadData card = new CardDownloadData("Emblem " + params[3], set, "0", false, type, "", "", true, fileName);
|
||||
card.setTokenClassName(tokenClassName);
|
||||
list.add(card);
|
||||
} else if (params[1].toLowerCase().equals("generate") && params[2].startsWith("EMBLEM-:")) {
|
||||
String set = params[2].substring(8);
|
||||
CardDownloadData card = new CardDownloadData(params[3] + " Emblem", set, "0", false, type, "", "", true, fileName);
|
||||
card.setTokenClassName(tokenClassName);
|
||||
list.add(card);
|
||||
} else if (params[1].toLowerCase().equals("generate") && params[2].startsWith("EMBLEM!:")) {
|
||||
String set = params[2].substring(8);
|
||||
CardDownloadData card = new CardDownloadData(params[3], set, "0", false, type, "", "", true, fileName);
|
||||
card.setTokenClassName(tokenClassName);
|
||||
list.add(card);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -27,10 +27,12 @@ public final class CardImageUtils {
|
|||
*/
|
||||
public static String generateTokenImagePath(CardDownloadData card) {
|
||||
if (card.isToken()) {
|
||||
if (pathCache.containsKey(card)) {
|
||||
return pathCache.get(card);
|
||||
}
|
||||
String filePath = getTokenImagePath(card);
|
||||
if (pathCache.containsKey(card)) {
|
||||
if (filePath.equals(pathCache.get(card))) {
|
||||
return pathCache.get(card);
|
||||
}
|
||||
}
|
||||
TFile file = new TFile(filePath);
|
||||
|
||||
if (!file.exists() && card.getTokenSetCode() != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue