* UI: fixed that tokens in M15 render mode did not use a variety of images (all same named tokens uses same image);

This commit is contained in:
Oleg Agafonov 2020-06-15 20:21:30 +04:00
parent fe3c2cc386
commit 2b21298377
4 changed files with 21 additions and 10 deletions

View file

@ -562,8 +562,8 @@ public class MageBook extends JComponent {
Constructor<?> cons = c.getConstructor();
Object newToken = cons.newInstance();
if (newToken instanceof Token) {
((Token) newToken).setExpansionSetCodeForImage(set);
((Token) newToken).setOriginalExpansionSetCode(set);
((Token) newToken).setExpansionSetCodeForImage(set);
((Token) newToken).setTokenType(token.getType());
tokens.add((Token) newToken);
}
@ -634,6 +634,10 @@ public class MageBook extends JComponent {
}
}
if (emblems.size() == 0) {
return emblems;
}
int totalTokens = getTotalNumTokens(set);
int start = 0;
if (!(page * conf.CARDS_PER_PAGE <= totalTokens && (page + 1) * conf.CARDS_PER_PAGE >= totalTokens)) {
@ -917,8 +921,8 @@ public class MageBook extends JComponent {
private int currentPage = 0;
private String currentSet = "RTR";
private int currentCardsInSet = 0;
private int currentCardsNotInSet = 0;
private final int currentCardsInSet = 0;
private final int currentCardsNotInSet = 0;
private static CardDimensions cardDimensions = new CardDimensions(1.2d);
private static final Logger log = Logger.getLogger(MageBook.class);

View file

@ -154,6 +154,7 @@ public class CardPanelRenderImpl extends CardPanel {
sb.append(this.view.getToughness());
sb.append(this.view.getLoyalty());
sb.append(this.view.getColor().toString());
sb.append(this.view.getType());
sb.append(this.view.getExpansionSetCode());
for (CardType type : this.view.getCardTypes()) {
sb.append((char) type.ordinal());
@ -227,7 +228,7 @@ public class CardPanelRenderImpl extends CardPanel {
private BufferedImage faceArtImage;
// Factory to generate card appropriate views
private CardRendererFactory cardRendererFactory = new CardRendererFactory();
private final CardRendererFactory cardRendererFactory = new CardRendererFactory();
// The rendered card image, with or without the art image loaded yet
// = null while invalid

View file

@ -47,7 +47,7 @@ public final class ImageCache {
private static final SoftValuesLoadingCache<String, BufferedImage> FACE_IMAGE_CACHE;
/**
* Common pattern for keys. Format: "<cardname>#<setname>#<collectorID>"
* Common pattern for keys. See ImageCache.getKey for structure info
*/
private static final Pattern KEY_PATTERN = Pattern.compile("(.*)#(.*)#(.*)#(.*)#(.*)#(.*)");
@ -428,11 +428,14 @@ public final class ImageCache {
* Returns the map key for a card, without any suffixes for the image size.
*/
private static String getKey(CardView card, String name, String suffix) {
return name + '#' + card.getExpansionSetCode() + '#' + card.getType() + '#' + card.getCardNumber() + '#'
+ (card.getTokenSetCode() == null ? "" : card.getTokenSetCode())
return name
+ '#' + card.getExpansionSetCode()
+ '#' + card.getType()
+ '#' + card.getCardNumber()
+ '#' + (card.getTokenSetCode() == null ? "" : card.getTokenSetCode())
+ suffix
+ (card.getUsesVariousArt() ? "#usesVariousArt" : "")
+ (card.getTokenDescriptor() != null ? '#' + card.getTokenDescriptor() : "#");
+ '#' + (card.getTokenDescriptor() != null ? card.getTokenDescriptor() : "");
}
/**

View file

@ -370,7 +370,10 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
copyAbility.setSourceId(objectId);
// triggered abilities must be added to the state().triggers
// still as long as the prev. permanent is known to the LKI (e.g. Showstopper) so gained dies triggered ability will trigger
game.getState().addAbility(copyAbility, sourceId, this);
if (game != null) {
// game is null in cards viewer window (MageBook)
game.getState().addAbility(copyAbility, sourceId, this);
}
abilities.add(copyAbility);
}
}
@ -400,7 +403,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
}
@Override
public void removeAbilities(List<Ability> abilitiesToRemove, UUID sourceId, Game game){
public void removeAbilities(List<Ability> abilitiesToRemove, UUID sourceId, Game game) {
if (abilitiesToRemove == null) {
return;
}