mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Face down cards use now the cardback image.
This commit is contained in:
parent
4cc454ba16
commit
37a1c9a6f9
3 changed files with 32 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
|||
package org.mage.card.arcane;
|
||||
|
||||
import de.schlichtherle.truezip.file.TFile;
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
|
@ -18,6 +19,7 @@ import java.awt.event.MouseMotionListener;
|
|||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -43,6 +45,7 @@ import mage.view.StackAbilityView;
|
|||
import org.apache.log4j.Logger;
|
||||
import org.mage.card.arcane.ScaledImagePanel.MultipassType;
|
||||
import org.mage.card.arcane.ScaledImagePanel.ScalingType;
|
||||
import org.mage.plugins.card.dl.sources.DirectLinksForDownload;
|
||||
import org.mage.plugins.card.images.ImageCache;
|
||||
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
|
||||
|
||||
|
@ -257,10 +260,16 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
try {
|
||||
tappedAngle = isTapped() ? CardPanel.TAPPED_ANGLE : 0;
|
||||
flippedAngle = isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
|
||||
if (!loadImage || gameCard.isFaceDown()) {
|
||||
if (!loadImage) {
|
||||
return;
|
||||
}
|
||||
BufferedImage srcImage = ImageCache.getImage(gameCard, getCardWidth(), getCardHeight());
|
||||
BufferedImage srcImage;
|
||||
if (gameCard.isFaceDown()) {
|
||||
TFile file = new TFile(DirectLinksForDownload.outDir + File.separator + DirectLinksForDownload.cardbackFilename);
|
||||
srcImage = ImageCache.loadImage(file);
|
||||
} else {
|
||||
srcImage = ImageCache.getImage(gameCard, getCardWidth(), getCardHeight());
|
||||
}
|
||||
if (srcImage != null) {
|
||||
hasImage = true;
|
||||
setText(gameCard);
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
package org.mage.plugins.card.dl.sources;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import org.mage.plugins.card.dl.DownloadJob;
|
||||
import static org.mage.plugins.card.dl.DownloadJob.fromURL;
|
||||
import static org.mage.plugins.card.dl.DownloadJob.toFile;
|
||||
|
||||
|
||||
/**
|
||||
* Used when we need to point to direct links to download resources from.
|
||||
*
|
||||
|
@ -22,7 +24,7 @@ public class DirectLinksForDownload implements Iterable<DownloadJob> {
|
|||
|
||||
private static final String backsideUrl = "http://upload.wikimedia.org/wikipedia/en/a/aa/Magic_the_gathering-card_back.jpg";
|
||||
|
||||
private static final Map<String, String> directLinks = new LinkedHashMap<String, String>();
|
||||
private static final Map<String, String> directLinks = new LinkedHashMap<>();
|
||||
|
||||
public static final String cardbackFilename = "cardback.jpg";
|
||||
public static final String tokenFrameFilename = "tokenFrame.png";
|
||||
|
@ -45,7 +47,7 @@ public class DirectLinksForDownload implements Iterable<DownloadJob> {
|
|||
|
||||
@Override
|
||||
public Iterator<DownloadJob> iterator() {
|
||||
ArrayList<DownloadJob> jobs = new ArrayList<DownloadJob>();
|
||||
ArrayList<DownloadJob> jobs = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, String> url : directLinks.entrySet()) {
|
||||
File dst = new File(outDir, url.getKey());
|
||||
|
|
|
@ -180,6 +180,21 @@ public class ImageCache {
|
|||
return getImage(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Image corresponding to the Path
|
||||
*/
|
||||
private static BufferedImage getImageByPath(String path) {
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
TFile file = new TFile(path);
|
||||
if (!file.exists()) {
|
||||
log.warn("File does not exist: " + file.toString());
|
||||
return null;
|
||||
}
|
||||
return getWizardsCard(loadImage(file));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Image corresponding to the key
|
||||
|
|
Loading…
Reference in a new issue