Added support for multiple images for a single card.

Added Unhinged basic lands as alternate image for basic lands.
master
ubeefx 2010-12-05 17:02:06 +00:00
parent c9f53dbe1b
commit 67d82326cb
16 changed files with 85 additions and 48 deletions

View File

@ -216,6 +216,7 @@ Flame-Kin Zealot.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiversei
Flametongue Kavu.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=205392&type=card
Flight of Fancy.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=83677&type=card
Forest.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?type=card&multiverseid=195158
Forest2.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=73946&type=card
Foul Imp.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=197012&type=card
Frenzied Goblin.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=87947&type=card
Furnace Whelp.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=189227&type=card
@ -265,6 +266,7 @@ Inkfathom Infiltrator.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiv
Inspirit.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=84552&type=card
Iridescent Angel.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=31799&type=card
Island.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?type=card&multiverseid=201966
Island2.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=73951&type=card
Jhessian Balmgiver.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=174791&type=card
Jhessian Infiltrator.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=175392&type=card
Jund Hackblade.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=188973&type=card
@ -329,6 +331,7 @@ Mordant Dragon.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=
Moroii.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=83631&type=card
Mortify.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=96930&type=card
Mountain.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?type=card&multiverseid=201968
Mountain2.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=73958&type=card
Murderous Redcap.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=153298&type=card
Murkfiend Liege.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=152091&type=card
Mystic Snake.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=109693&type=card
@ -350,6 +353,7 @@ Perimeter Captain.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverse
Phyrexian Arena.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=205417&type=card
Pillory of the Sleepless.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=96882&type=card
Plains.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?type=card&multiverseid=195179
Plains2.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=73963&type=card
Platinum Angel.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=206329&type=card
Plumeveil.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=153980&type=card
Plummet.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=220514&type=card
@ -459,6 +463,7 @@ Stupor.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=108923&t
Sunpetal Grove.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=205124&type=card
Surveilling Sprite.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=87904&type=card
Swamp.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?type=card&multiverseid=201977
Swamp2.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=73973&type=card
Sword of Fire and Ice.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=46429&type=card
Sword of Light and Shadow.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=47453&type=card
Sword of Vengeance.jpg;http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=205044&type=card

View File

@ -17,6 +17,7 @@ import magic.model.MagicCardDefinition;
public class CardImages {
public static final String IMAGE_EXTENSION=".jpg";
public static final int CARD_WIDTH=203;
public static final int CARD_HEIGHT=289;
public static final int CARD_FULL_WIDTH=223;
@ -24,16 +25,23 @@ public class CardImages {
private static final CardImages INSTANCE=new CardImages();
private final Map<MagicCardDefinition,BufferedImage> imagesMap;
private final Map<MagicCardDefinition,BufferedImage[]> imagesMap;
private CardImages() {
imagesMap=new HashMap<MagicCardDefinition,BufferedImage>();
imagesMap=new HashMap<MagicCardDefinition,BufferedImage[]>();
}
private String getFilename(final MagicCardDefinition card) {
private String[] getFilenames(final MagicCardDefinition card) {
final String filenames[]=new String[card.getImageCount()];
final String imagePath=MagicMain.getGamePath()+File.separator+(card.isToken()?"tokens":"cards")+File.separator;
final String imageFilename=card.getImageName();
for (int index=0;index<card.getImageCount();index++) {
return MagicMain.getGamePath()+File.separator+(card.isToken()?"tokens":"cards")+File.separator+card.getImageName();
filenames[index]=imagePath+imageFilename+(index>0?String.valueOf(index+1):"")+IMAGE_EXTENSION;
}
return filenames;
}
private static BufferedImage loadCardImage(final String filename) {
@ -59,25 +67,29 @@ public class CardImages {
}
}
public BufferedImage getImage(final MagicCardDefinition card) {
public BufferedImage getImage(final MagicCardDefinition card,final int index) {
if (card==null) {
return IconImages.MISSING;
}
synchronized (imagesMap) {
final BufferedImage image=imagesMap.get(card);
if (image!=null) {
return image;
final BufferedImage images[]=imagesMap.get(card);
if (images!=null) {
return images[index%images.length];
}
}
final String filename=getFilename(card);
final BufferedImage image=loadCardImage(filename);
final String[] filenames=getFilenames(card);
final BufferedImage images[]=new BufferedImage[filenames.length];
for (int i=0;i<filenames.length;i++) {
images[i]=loadCardImage(filenames[i]);
}
synchronized (imagesMap) {
imagesMap.put(card,image);
return image;
imagesMap.put(card,images);
return images[index%images.length];
}
}

View File

@ -15,12 +15,14 @@ public class MagicCard implements MagicSource,MagicTarget,Comparable<MagicCard>
private boolean token=false;
private boolean known=true;
private int id;
private int imageIndex=0;
public MagicCard(final MagicCardDefinition cardDefinition,final MagicPlayer owner,final int id) {
this.cardDefinition=cardDefinition;
this.owner=owner;
this.id=id;
imageIndex=MagicRandom.nextInt(100);
}
public MagicCard(final MagicDeckCard card,final MagicPlayer owner,final int id) {
@ -64,6 +66,11 @@ public class MagicCard implements MagicSource,MagicTarget,Comparable<MagicCard>
return id;
}
public int getImageIndex() {
return imageIndex;
}
public MagicCardDefinition getCardDefinition() {

View File

@ -53,7 +53,6 @@ public class MagicCardDefinition {
public static final Color RARITY_COLORS[]={COMMON_COLOR,COMMON_COLOR,UNCOMMON_COLOR,RARE_COLOR};
public static final String RARITY_NAMES[]={"Basic","Common","Uncommon","Rare"};
public static final int NR_OF_RARITIES=4;
public static final String IMAGE_EXTENSION=".jpg";
public static final List<MagicLocalVariable> DEFAULT_LOCAL_VARIABLES=Arrays.<MagicLocalVariable>asList(MagicStaticLocalVariable.getInstance());
@ -127,7 +126,12 @@ public class MagicCardDefinition {
public String getImageName() {
return fullName+IMAGE_EXTENSION;
return fullName;
}
public int getImageCount() {
return hasType(MagicType.Basic)?2:1;
}
public void setValue(final int value) {

View File

@ -60,7 +60,7 @@ public class ExplorerPanel extends JPanel implements ActionListener {
cardViewer=new CardViewer(false);
cardViewer.setSize(CARD_WIDTH,CARD_HEIGHT);
cardViewer.setCard(null);
cardViewer.setCard(null,0);
add(cardViewer);
filterPanel=new ExplorerFilterPanel(this);
@ -130,9 +130,9 @@ public class ExplorerPanel extends JPanel implements ActionListener {
private void update() {
if (cardDefinitions.isEmpty()) {
cardViewer.setCard(null);
cardViewer.setCard(null,0);
} else {
cardViewer.setCard(cardDefinitions.get(0));
cardViewer.setCard(cardDefinitions.get(0),0);
}
cardsPanel.removeAll();
@ -220,7 +220,7 @@ public class ExplorerPanel extends JPanel implements ActionListener {
@Override
public void mouseEntered(final MouseEvent event) {
CardLabel.this.cardViewer.setCard(CardLabel.this.cardDefinition);
CardLabel.this.cardViewer.setCard(CardLabel.this.cardDefinition,0);
}
});
}

View File

@ -14,6 +14,7 @@ import javax.swing.SwingUtilities;
import magic.ai.ArtificialWorkerPool;
import magic.data.IconImages;
import magic.model.MagicCard;
import magic.model.MagicCardDefinition;
import magic.model.MagicGame;
import magic.model.MagicSource;
@ -141,12 +142,17 @@ public class GameController {
this.gameViewer=gameViewer;
}
public void viewCard(final MagicCardDefinition cardDefinition) {
cardViewer.setCard(cardDefinition);
public void viewCard(final MagicCard card) {
cardViewer.setCard(card.getCardDefinition(),card.getImageIndex());
}
public void viewInfoAbove(final MagicCardDefinition cardDefinition,final Rectangle rect) {
public void viewCard(final MagicCardDefinition cardDefinition,final int index) {
cardViewer.setCard(cardDefinition,index);
}
public void viewInfoAbove(final MagicCardDefinition cardDefinition,final int index,final Rectangle rect) {
final Dimension size=gamePanel.getSize();
final Point pointOnScreen=gamePanel.getLocationOnScreen();
@ -160,12 +166,12 @@ public class GameController {
if (y<10) {
y=rect.y+rect.height+6;
}
imageCardViewer.setCard(cardDefinition);
imageCardViewer.setCard(cardDefinition,index);
imageCardViewer.setLocation(x,y);
DelayedViewersThread.getInstance().showViewer(imageCardViewer,CARD_VIEW_DELAY);
}
public void viewInfoRight(final MagicCardDefinition cardDefinition,final Rectangle rect) {
public void viewInfoRight(final MagicCardDefinition cardDefinition,final int index,final Rectangle rect) {
final Dimension size=gamePanel.getSize();
final Point pointOnScreen=gamePanel.getLocationOnScreen();
@ -179,7 +185,7 @@ public class GameController {
} else if (y>maxY) {
y=maxY;
}
imageCardViewer.setCard(cardDefinition);
imageCardViewer.setCard(cardDefinition,index);
imageCardViewer.setLocation(x,y);
DelayedViewersThread.getInstance().showViewer(imageCardViewer,CARD_VIEW_DELAY);
}

View File

@ -52,7 +52,7 @@ public class BasicLandPermanentButton extends PanelButton implements ChoiceViewe
@Override
public void mouseEntered() {
controller.viewCard(permanentInfo.cardDefinition);
controller.viewCard(permanentInfo.cardDefinition,permanentInfo.index);
}
@Override

View File

@ -63,7 +63,8 @@ public abstract class CardListViewer extends JPanel implements ChoiceViewer {
final MagicCardList cardList=getCardList();
if (cardList.size()>0) {
controller.viewCard(cardList.getCardAtBottom().getCardDefinition());
final MagicCard bottomCard=cardList.getCardAtBottom();
controller.viewCard(bottomCard);
}
}
@ -147,7 +148,7 @@ public abstract class CardListViewer extends JPanel implements ChoiceViewer {
@Override
public void mouseEntered() {
controller.viewCard(card.getCardDefinition());
controller.viewCard(card);
}
@Override

View File

@ -17,7 +17,8 @@ public class CardViewer extends JPanel {
private final JLabel cardLabel;
private MagicCardDefinition currentCardDefinition=null;
private int currentIndex=0;
public CardViewer(final boolean image) {
this.setLayout(new BorderLayout());
@ -32,14 +33,15 @@ public class CardViewer extends JPanel {
cardLabel=new JLabel();
add(cardLabel,BorderLayout.CENTER);
setCard(MagicCardDefinition.EMPTY);
setCard(MagicCardDefinition.EMPTY,0);
}
public void setCard(final MagicCardDefinition cardDefinition) {
public void setCard(final MagicCardDefinition cardDefinition,final int index) {
if (cardDefinition!=currentCardDefinition) {
if (cardDefinition!=currentCardDefinition||index!=currentIndex) {
currentCardDefinition=cardDefinition;
cardLabel.setIcon(new ImageIcon(CardImages.getInstance().getImage(cardDefinition)));
currentIndex=index;
cardLabel.setIcon(new ImageIcon(CardImages.getInstance().getImage(cardDefinition,index)));
repaint();
}
}

View File

@ -68,7 +68,7 @@ public class DeckViewer extends JPanel implements ChangeListener {
private void setCardImage(final DeckEntry entry) {
cardViewer.setCard(entry.card);
cardViewer.setCard(entry.card,0);
}
public void setNameFont(final Font nameFont) {

View File

@ -98,10 +98,10 @@ public class GameViewer extends TexturedPanel implements ActionListener {
final MagicCardDefinition cardDefinition=controller.getSourceCardDefinition();
if (cardDefinition!=null) {
if (GeneralConfig.getInstance().getTextView()) {
controller.viewCard(cardDefinition);
controller.viewCard(cardDefinition,0);
} else {
final Point point=getLocationOnScreen();
controller.viewInfoAbove(cardDefinition,new Rectangle(point.x,point.y-20,getWidth(),getHeight()));
controller.viewInfoAbove(cardDefinition,0,new Rectangle(point.x,point.y-20,getWidth(),getHeight()));
}
}
}

View File

@ -18,7 +18,6 @@ import javax.swing.JPanel;
import magic.data.CardImages;
import magic.model.MagicCard;
import magic.model.MagicCardDefinition;
import magic.model.MagicCardList;
import magic.ui.GameController;
import magic.ui.widget.FontsAndBorders;
@ -73,11 +72,11 @@ public class ImageCardListViewer extends JPanel implements ChoiceViewer {
final int index=getCardIndexAt(event.getX(),event.getY());
if (index>=0) {
final MagicCardDefinition cardDefinition=cardList.get(index).getCardDefinition();
final MagicCard card=cardList.get(index);
final Point pointOnScreen=getLocationOnScreen();
final Point point=cardPoints.get(index);
final Rectangle rect=new Rectangle(pointOnScreen.x+point.x,pointOnScreen.y+point.y,CARD_WIDTH,CARD_HEIGHT);
ImageCardListViewer.this.controller.viewInfoAbove(cardDefinition,rect);
ImageCardListViewer.this.controller.viewInfoAbove(card.getCardDefinition(),card.getImageIndex(),rect);
} else {
ImageCardListViewer.this.controller.hideInfo();
}
@ -121,7 +120,7 @@ public class ImageCardListViewer extends JPanel implements ChoiceViewer {
this.cardList=cardList;
this.cardPoints=cardPoints;
}
@Override
public void paint(final Graphics g) {
@ -138,7 +137,7 @@ public class ImageCardListViewer extends JPanel implements ChoiceViewer {
final MagicCard card=cardList.get(index);
final Point point=cardPoints.get(index);
final BufferedImage image=CardImages.getInstance().getImage(card.getCardDefinition());
final BufferedImage image=CardImages.getInstance().getImage(card.getCardDefinition(),card.getImageIndex());
g.drawImage(image,point.x,point.y,point.x+CARD_WIDTH,point.y+CARD_HEIGHT,0,0,CardImages.CARD_WIDTH,CardImages.CARD_HEIGHT,this);
if (validChoices.contains(card)) {
g2d.fillRect(point.x-1,point.y-1,CARD_WIDTH+2,CARD_HEIGHT+2);

View File

@ -22,7 +22,6 @@ import javax.swing.JPanel;
import magic.data.CardImages;
import magic.data.IconImages;
import magic.model.MagicAbility;
import magic.model.MagicCardDefinition;
import magic.ui.widget.FontsAndBorders;
public class ImagePermanentViewer extends JPanel {
@ -79,12 +78,12 @@ public class ImagePermanentViewer extends JPanel {
final int index=getPermanentInfoIndexAt(event.getX(),event.getY());
if (index>=0) {
final MagicCardDefinition cardDefinition=linkedInfos.get(index).cardDefinition;
final PermanentViewerInfo info=linkedInfos.get(index);
final Point pointOnScreen=getLocationOnScreen();
final Rectangle rect=new Rectangle(linkedScreenRectangles.get(index));
rect.x+=pointOnScreen.x;
rect.y+=pointOnScreen.y;
viewer.getController().viewInfoAbove(cardDefinition,rect);
viewer.getController().viewInfoAbove(info.cardDefinition,info.index,rect);
} else {
viewer.getController().hideInfo();
}
@ -213,7 +212,7 @@ public class ImagePermanentViewer extends JPanel {
for (int index=0;index<linkedScreenRectangles.size();index++) {
final PermanentViewerInfo linkedInfo=linkedInfos.get(index);
final BufferedImage image=CardImages.getInstance().getImage(linkedInfo.cardDefinition);
final BufferedImage image=CardImages.getInstance().getImage(linkedInfo.cardDefinition,linkedInfo.index);
final Rectangle linkedRect=linkedScreenRectangles.get(index);
final int x1=linkedRect.x;
final int y1=linkedRect.y;

View File

@ -64,7 +64,7 @@ public class PermanentButton extends PanelButton implements ChoiceViewer {
@Override
public void mouseEntered() {
controller.viewCard(permanentInfo.cardDefinition);
controller.viewCard(permanentInfo.cardDefinition,permanentInfo.index);
}
@Override

View File

@ -39,6 +39,7 @@ public class PermanentViewerInfo {
public final MagicCardDefinition cardDefinition;
public final String name;
public final ImageIcon icon;
public final int index;
public final String powerToughness;
public final String text;
public final long abilityFlags;
@ -66,6 +67,7 @@ public class PermanentViewerInfo {
cardDefinition=permanent.getCardDefinition();
name=permanent.getName();
icon=permanent.getIcon();
index=permanent.getCard().getImageIndex();
powerToughness=getPowerToughness(game,permanent);
abilityFlags=permanent.getAllAbilityFlags(game);
text=getText(game,permanent,abilityFlags);

View File

@ -138,9 +138,9 @@ public class StackViewer extends JPanel implements ChoiceViewer {
if (image) {
final Rectangle rect=new Rectangle(StackViewer.this.getLocationOnScreen().x,getLocationOnScreen().y,StackViewer.this.getWidth(),getHeight());
controller.viewInfoRight(stackInfo.cardDefinition,rect);
controller.viewInfoRight(stackInfo.cardDefinition,0,rect);
} else {
controller.viewCard(stackInfo.cardDefinition);
controller.viewCard(stackInfo.cardDefinition,0);
}
}