diff --git a/.gitattributes b/.gitattributes index 4d9481e1021..226e6e31b3e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -17,8 +17,10 @@ res/lang/en.properties svneol=native#text/plain res/lang/howTo/de.properties svneol=native#text/plain res/lang/howTo/en.properties svneol=native#text/plain res/lang/lang.properties svneol=native#text/plain +res/lib/google-collect-1.0.jar -text svneol=unset#unset res/lib/jdom-1.0.jar -text svneol=unset#unset res/lib/jl1.0.1.jar -text svneol=unset#unset +res/lib/jsr305.jar -text svneol=unset#unset res/lib/napkinlaf-1.2.jar -text svneol=unset#unset res/lib/napkinlaf-swingset-1.2.jar -text svneol=unset#unset res/lib/nimrodlf.jar -text svneol=unset#unset @@ -68,6 +70,8 @@ src/Deck.java svneol=native#text/plain src/DeckConverter.java svneol=native#text/plain src/OldDeckIO.java svneol=native#text/plain src/QuestData_State.java svneol=native#text/plain +src/arcane/ui/ScaledImagePanel.java -text svneol=native#text/plain +src/arcane/ui/util/ImageUtil.java -text svneol=native#text/plain src/com/cloudgarden/layout/AnchorConstraint.java -text svneol=native#text/plain src/com/cloudgarden/layout/AnchorLayout.java -text svneol=native#text/plain src/forge/Ability.java svneol=native#text/plain diff --git a/res/cards.txt b/res/cards.txt index 8f303fcee4b..909a7ec2a3e 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,22 @@ +Goblin Guide +R +Creature Goblin +Whenever Goblin Guide attacks, defending player reveals the top card of his or her library. If it's a land card, that player puts it into his or her hand. +2/2 +Haste + +Overbeing of Myth +GU GU GU GU GU +Creature Spirit Avatar +Overbeing of Myth's power and toughness are each equal to the number of cards in your hand. At the beginning of your draw step, draw an additional card. +0/0 + +Wanderbrine Rootcutters +2 UB UB +Creature Merfolk Rogue +Wanderbrine Rootcutters can't be blocked by green creatures. +3/3 + Time Vault 2 Artifact diff --git a/res/lib/google-collect-1.0.jar b/res/lib/google-collect-1.0.jar new file mode 100644 index 00000000000..a7abdbbdb4e Binary files /dev/null and b/res/lib/google-collect-1.0.jar differ diff --git a/res/lib/jsr305.jar b/res/lib/jsr305.jar new file mode 100644 index 00000000000..cf5f5616789 Binary files /dev/null and b/res/lib/jsr305.jar differ diff --git a/res/main.properties b/res/main.properties index e6aea9d48d8..376c8f17d16 100644 --- a/res/main.properties +++ b/res/main.properties @@ -1,6 +1,6 @@ program/mail=mtgerror@yahoo.com program/forum=http://www.slightlymagic.net/forum/viewforum.php?f=26 -program/version=Forge -- official beta: 10/01/01, SVN revision: 268 +program/version=Forge -- official beta: 10/01/01, SVN revision: 269 tokens--file=AllTokens.txt diff --git a/src/arcane/ui/ScaledImagePanel.java b/src/arcane/ui/ScaledImagePanel.java new file mode 100644 index 00000000000..9bb5a4cd9fb --- /dev/null +++ b/src/arcane/ui/ScaledImagePanel.java @@ -0,0 +1,194 @@ + package arcane.ui; + + import java.awt.Graphics; + import java.awt.Graphics2D; + import java.awt.Image; + import java.awt.RenderingHints; + import java.awt.image.BufferedImage; + + import javax.swing.JPanel; + + public class ScaledImagePanel extends JPanel { + + private static final long serialVersionUID = -5691107238620895385L; + public volatile Image srcImage; + public volatile Image srcImageBlurred; + + private ScalingType scalingType = ScalingType.bilinear; + private boolean scaleLarger; + private MultipassType multiPassType = MultipassType.bilinear; + private boolean blur; + + public ScaledImagePanel () { + super(false); + setOpaque(false); + } + + public void setImage (Image srcImage, Image srcImageBlurred) { + this.srcImage = srcImage; + this.srcImageBlurred = srcImageBlurred; + } + + public void clearImage () { + srcImage = null; + srcImageBlurred = null; + repaint(); + } + + public void setScalingMultiPassType (MultipassType multiPassType) { + this.multiPassType = multiPassType; + } + + public void setScalingType (ScalingType scalingType) { + this.scalingType = scalingType; + } + + public void setScalingBlur (boolean blur) { + this.blur = blur; + } + + public void setScaleLarger (boolean scaleLarger) { + this.scaleLarger = scaleLarger; + } + + public boolean hasImage () { + return srcImage != null; + } + + private ScalingInfo getScalingInfo () { + int panelWidth = getWidth(); + int panelHeight = getHeight(); + int srcWidth = srcImage.getWidth(null); + int srcHeight = srcImage.getHeight(null); + int targetWidth = srcWidth; + int targetHeight = srcHeight; + if (scaleLarger || srcWidth > panelWidth || srcHeight > panelHeight) { + targetWidth = Math.round(panelHeight * (srcWidth / (float)srcHeight)); + if (targetWidth > panelWidth) { + targetHeight = Math.round(panelWidth * (srcHeight / (float)srcWidth)); + targetWidth = panelWidth; + } else + targetHeight = panelHeight; + } + ScalingInfo info = new ScalingInfo(); + info.targetWidth = targetWidth; + info.targetHeight = targetHeight; + info.srcWidth = srcWidth; + info.srcHeight = srcHeight; + info.x = panelWidth / 2 - targetWidth / 2; + info.y = panelHeight / 2 - targetHeight / 2; + return info; + } + + public void paint (Graphics g) { + if (srcImage == null) return; + + Graphics2D g2 = (Graphics2D)g.create(); + ScalingInfo info = getScalingInfo(); + + switch (scalingType) { + case nearestNeighbor: + scaleWithDrawImage(g2, info, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); + break; + case bilinear: + scaleWithDrawImage(g2, info, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + break; + case bicubic: + scaleWithDrawImage(g2, info, RenderingHints.VALUE_INTERPOLATION_BICUBIC); + break; + case areaAveraging: + scaleWithGetScaledInstance(g2, info, Image.SCALE_AREA_AVERAGING); + break; + case replicate: + scaleWithGetScaledInstance(g2, info, Image.SCALE_REPLICATE); + break; + } + } + + private void scaleWithGetScaledInstance (Graphics2D g2, ScalingInfo info, int hints) { + Image srcImage = getSourceImage(info); + Image scaledImage = srcImage.getScaledInstance(info.targetWidth, info.targetHeight, hints); + g2.drawImage(scaledImage, info.x, info.y, null); + } + + private void scaleWithDrawImage (Graphics2D g2, ScalingInfo info, Object hint) { + g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint); + + int tempDestWidth = info.srcWidth / 2, tempDestHeight = info.srcHeight / 2; + if (tempDestWidth < info.targetWidth) tempDestWidth = info.targetWidth; + if (tempDestHeight < info.targetHeight) tempDestHeight = info.targetHeight; + + Image srcImage = getSourceImage(info); + + // If not doing multipass or multipass only needs a single pass, just scale it once directly to the panel surface. + if (multiPassType == MultipassType.none || (tempDestWidth == info.targetWidth && tempDestHeight == info.targetHeight)) { + g2.drawImage(srcImage, info.x, info.y, info.targetWidth, info.targetHeight, null); + return; + } + + BufferedImage tempImage = new BufferedImage(tempDestWidth, tempDestHeight, BufferedImage.TYPE_INT_RGB); + Graphics2D g2temp = tempImage.createGraphics(); + switch (multiPassType) { + case nearestNeighbor: + g2temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); + break; + case bilinear: + g2temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + break; + case bicubic: + g2temp.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); + break; + } + // Render first pass from image to temp. + g2temp.drawImage(srcImage, 0, 0, tempDestWidth, tempDestHeight, null); + // Render passes between the first and last pass. + int tempSrcWidth = tempDestWidth; + int tempSrcHeight = tempDestHeight; + while (true) { + if (tempDestWidth > info.targetWidth) { + tempDestWidth = tempDestWidth / 2; + if (tempDestWidth < info.targetWidth) tempDestWidth = info.targetWidth; + } + + if (tempDestHeight > info.targetHeight) { + tempDestHeight = tempDestHeight / 2; + if (tempDestHeight < info.targetHeight) tempDestHeight = info.targetHeight; + } + + if (tempDestWidth == info.targetWidth && tempDestHeight == info.targetHeight) break; + + g2temp.drawImage(tempImage, 0, 0, tempDestWidth, tempDestHeight, 0, 0, tempSrcWidth, tempSrcHeight, null); + + tempSrcWidth = tempDestWidth; + tempSrcHeight = tempDestHeight; + } + g2temp.dispose(); + // Render last pass from temp to panel surface. + g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint); + g2.drawImage(tempImage, info.x, info.y, info.x + info.targetWidth, info.y + info.targetHeight, 0, 0, tempSrcWidth, + tempSrcHeight, null); + } + + private Image getSourceImage (ScalingInfo info) { + if (!blur || srcImageBlurred == null) return srcImage; + if (info.srcWidth / 2 < info.targetWidth || info.srcHeight / 2 < info.targetHeight) return srcImage; + return srcImageBlurred; + } + + static private class ScalingInfo { + public int targetWidth; + public int targetHeight; + public int srcWidth; + public int srcHeight; + public int x; + public int y; + } + + static public enum MultipassType { + none, nearestNeighbor, bilinear, bicubic + } + + static public enum ScalingType { + nearestNeighbor, replicate, bilinear, bicubic, areaAveraging + } + } diff --git a/src/arcane/ui/util/ImageUtil.java b/src/arcane/ui/util/ImageUtil.java new file mode 100644 index 00000000000..9b3d190772a --- /dev/null +++ b/src/arcane/ui/util/ImageUtil.java @@ -0,0 +1,31 @@ + package arcane.ui.util; + + import java.awt.Graphics2D; + import java.awt.Image; + import java.awt.image.BufferedImage; + import java.awt.image.ConvolveOp; + import java.awt.image.Kernel; + import java.io.IOException; + import java.io.InputStream; + + import javax.imageio.ImageIO; + + public class ImageUtil { + static public BufferedImage getImage (InputStream stream) throws IOException { + Image tempImage = ImageIO.read(stream); + BufferedImage image = new BufferedImage(tempImage.getWidth(null), tempImage.getHeight(null), BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + g2.drawImage(tempImage, 0, 0, null); + g2.dispose(); + return image; + } + + static public BufferedImage getBlurredImage (BufferedImage image, int radius, float intensity) { + float weight = intensity / (radius * radius); + float[] elements = new float[radius * radius]; + for (int i = 0, n = radius * radius; i < n; i++) + elements[i] = weight; + ConvolveOp blurOp = new ConvolveOp(new Kernel(radius, radius, elements)); + return blurOp.filter(image, null); + } + } diff --git a/src/forge/CombatUtil.java b/src/forge/CombatUtil.java index 8bcf80cf169..1c74da46486 100644 --- a/src/forge/CombatUtil.java +++ b/src/forge/CombatUtil.java @@ -140,6 +140,13 @@ public class CombatUtil return false; } + if (attacker.getName().equals("Wanderbrine Rootcutters")) + { + if (CardUtil.getColors(blocker).contains(Constant.Color.Green)) + return false; + } + + if (attacker.getName().equals("Amrou Seekers")) { if (!blocker.getType().contains("Artifact") && @@ -1572,6 +1579,33 @@ public class CombatUtil }//Sapling of Colfenor + + else if(c.getName().equals("Goblin Guide") && !c.getCreatureAttackedThisTurn()) + { + final String opp = AllZone.GameAction.getOpponent(c.getController()); + + Ability ability = new Ability(c, "0") + { + public void resolve() + { + PlayerZone lib = AllZone.getZone(Constant.Zone.Library, opp); + if (lib.size() > 0) + { + CardList cl = new CardList(); + cl.add(lib.get(0)); + AllZone.Display.getChoiceOptional("Top card:", cl.toArray()); + + Card c = cl.get(0); + if(c.isLand()) { + AllZone.GameAction.moveToHand(c); + } + } + } + }; + ability.setStackDescription("Goblin Guide - defending player reveals the top card of his or her library. If it's a land card, that player puts it into his or her hand."); + AllZone.Stack.add(ability); + }//Goblin Guide + c.setCreatureAttackedThisTurn(true); }//if Phase = declare attackers diff --git a/src/forge/GameAction.java b/src/forge/GameAction.java index 7faacd53fe1..f19fffba677 100644 --- a/src/forge/GameAction.java +++ b/src/forge/GameAction.java @@ -1353,7 +1353,8 @@ private int getDifferentLand(CardList list, String land) int damageToAdd = damage; //AllZone.GameAction.addDamage(c, crd , assignedDamageMap.get(crd)); - if (source.getKeyword().contains("Wither")) + if (source.getKeyword().contains("Wither") && + card.isCreature()) { damageToAdd = 0; card.addCounter(Counters.M1M1, damage); @@ -1390,7 +1391,8 @@ private int getDifferentLand(CardList list, String land) public void addDamage(Card card, Card source, int damage) { int damageToAdd = damage; - if (source.getKeyword().contains("Wither")) + if (source.getKeyword().contains("Wither") && + card.isCreature()) { damageToAdd = 0; card.addCounter(Counters.M1M1, damage); diff --git a/src/forge/GameActionUtil.java b/src/forge/GameActionUtil.java index 790e099975a..02523a25019 100644 --- a/src/forge/GameActionUtil.java +++ b/src/forge/GameActionUtil.java @@ -86,6 +86,7 @@ public class GameActionUtil // cause black vise to do an extra point of // damage if black vise was in play upkeep_Font_of_Mythos(); + upkeep_Overbeing_of_Myth(); upkeep_AI_Aluren(); // experimental, just have the AI dump his small // creats in play when aluren is there @@ -7567,6 +7568,20 @@ public class GameActionUtil } }// upkeep_Font_of_Mythos() + private static void upkeep_Overbeing_of_Myth() + { + final String player = AllZone.Phase.getActivePlayer(); + + CardList list = new CardList(); + list.addAll(AllZone.Human_Play.getCards()); + list.addAll(AllZone.Computer_Play.getCards()); + + list = list.getName("Overbeing of Myth"); + + for (int i = 0; i < list.size(); i++) + AllZone.GameAction.drawCard(player); + }// upkeep_Overbeing_of_Myth() + private static void upkeep_Carnophage() { final String player = AllZone.Phase.getActivePlayer(); @@ -13997,6 +14012,45 @@ public class GameActionUtil };//Maro + public static Command Overbeing_of_Myth = new Command() + { + private static final long serialVersionUID = -2250795040532050455L; + public void execute() + { + // get all creatures + CardList list = new CardList(); + list.addAll(AllZone.Human_Play.getCards()); + list.addAll(AllZone.Computer_Play.getCards()); + list = list.getName("Overbeing of Myth"); + + for (int i = 0; i < list.size(); i++) + { + Card c = list.get(i); + int k = 0; + if (c.getController().equals(Constant.Player.Human)) + {k = countHand_Human ();} + else k = countHand_Computer(); + c.setBaseAttack(k); + c.setBaseDefense(k); + } + } + private int countHand_Human() + { + PlayerZone Play = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Human); + CardList list = new CardList(); + list.addAll(Play.getCards()); + return list.size(); + } + private int countHand_Computer() + { + PlayerZone Play = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer); + CardList list = new CardList(); + list.addAll(Play.getCards()); + return list.size(); + } + + };//overbeing of myth + public static Command Guul_Draz_Specter = new Command() { private static final long serialVersionUID = -8778902687347191964L; @@ -16088,6 +16142,7 @@ public class GameActionUtil commands.put("Multani_Maro_Sorcerer", Multani_Maro_Sorcerer); commands.put("Molimo_Maro_Sorcerer", Molimo_Maro_Sorcerer); commands.put("Maro", Maro); + commands.put("Overbeing_of_Myth", Overbeing_of_Myth); commands.put("Guul_Draz_Specter", Guul_Draz_Specter); commands.put("Dakkon", Dakkon); commands.put("Korlash", Korlash); diff --git a/src/forge/GuiDisplay3.java b/src/forge/GuiDisplay3.java index 46bed935dad..0cb2b3f2277 100644 --- a/src/forge/GuiDisplay3.java +++ b/src/forge/GuiDisplay3.java @@ -24,6 +24,7 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionAdapter; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; import java.beans.XMLDecoder; import java.beans.XMLEncoder; import java.io.BufferedInputStream; @@ -32,9 +33,13 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; import java.util.Observable; import java.util.Observer; +import java.util.concurrent.ConcurrentMap; +import javax.imageio.ImageIO; import javax.swing.Action; import javax.swing.BorderFactory; import javax.swing.BoxLayout; @@ -61,6 +66,12 @@ import javax.swing.event.ListSelectionListener; import org.jdesktop.swingx.MultiSplitPane; import org.jdesktop.swingx.MultiSplitLayout.Node; +import com.google.common.collect.MapMaker; +//import org.omg.CORBA.portable.InputStream; + +import arcane.ui.ScaledImagePanel; +import arcane.ui.ScaledImagePanel.ScalingType; + import forge.error.ErrorViewer; import forge.gui.ForgeAction; import forge.gui.ListChooser; @@ -87,6 +98,7 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon public Color c3 = new Color(204,204,204); */ + private ConcurrentMap imageCache = new MapMaker().softValues().makeMap(); private String current_picture = ""; //private int count = 0; @@ -561,6 +573,7 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon //picture //System.out.println("UPDATING PICTURE!!! #:" + count++); + /* current_picture = c.getImageName(); picturePanel.removeAll(); JPanel pic = GuiDisplayUtil.getPicture(c); @@ -568,6 +581,48 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon picturePanel.add(pic); picturePanel.revalidate(); System.gc(); + */ + + current_picture = c.getImageName(); + + BufferedImage srcImage = null; + if(imageCache.containsKey(c.getImageName())) + srcImage = imageCache.get(c.getImageName()); + else { + InputStream stream; + try { + //stream = new URL(GuiDisplayUtil.getURL(c)).openStream(); + stream = GuiDisplayUtil.getURL(c).openStream(); + srcImage = ImageIO.read(stream); + imageCache.put(c.getImageName(), srcImage); + } catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + //BufferedImage srcImageBlurred = arcane.ui.util.ImageUtil.getBlurredImage(srcImage, 3, 1.0f); // get a blurred image + cardImagePanel.setImage(srcImage, srcImage); + cardImagePanel.repaint(); + + /* + BufferedInputStream stream = (BufferedInputStream) GuiDisplayUtil.getPictureStream(c); + BufferedImage srcImage; + try { + srcImage = arcane.ui.util.ImageUtil.getImage(stream); + BufferedImage srcImageBlurred = arcane.ui.util.ImageUtil.getBlurredImage(srcImage, 3, 1.0f); // get a blurred image + + cardImagePanel.setImage(srcImage, srcImageBlurred); + cardImagePanel.repaint(); + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } // only need stream + */ //System.out.println(picturePanel.getComponentCount()); }//updateCardDetail() @@ -1141,10 +1196,21 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon //~ picturePanel.setBorder(new EtchedBorder()); + /* picturePanel.setLayout(new BoxLayout(picturePanel, BoxLayout.Y_AXIS)); picturePanel.setBackground(c1); picturePanel.addMouseListener(new CustomListener()); pane.add(new ExternalPanel(picturePanel), "picture"); + */ + + cardImagePanel.setScalingBlur(true); //use blured image if scaling down more than 50% + cardImagePanel.setScaleLarger(true); //upscale if needed true + cardImagePanel.setScalingType(ScalingType.bicubic); // type of scaling bicubic has good quality / speed ratio + + cardImagePanel.setLayout(new BoxLayout(cardImagePanel, BoxLayout.Y_AXIS)); + cardImagePanel.setBackground(c1); + cardImagePanel.addMouseListener(new CustomListener()); + pane.add(new ExternalPanel(cardImagePanel), "picture"); } private void cancelButtonActionPerformed(ActionEvent evt) { @@ -1190,6 +1256,7 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon JPanel cdPanel = new JPanel(); //JPanel picturePanel = new JPanel(); public JPanel picturePanel = new JPanel(); + JLabel oppLifeLabel = new JLabel(); JLabel playerLifeLabel = new JLabel(); JLabel oppPCLabel = new JLabel(); @@ -1211,6 +1278,9 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon JLabel playerFBValue = new JLabel(); JLabel playerRemovedValue = new JLabel(); + + ScaledImagePanel cardImagePanel = new ScaledImagePanel(); // < our JPanel + private class ZoneAction extends ForgeAction { private static final long serialVersionUID = -5822976087772388839L; private PlayerZone zone; diff --git a/src/forge/GuiDisplayUtil.java b/src/forge/GuiDisplayUtil.java index 4df4fdfd210..b5a25c3a3e3 100644 --- a/src/forge/GuiDisplayUtil.java +++ b/src/forge/GuiDisplayUtil.java @@ -9,8 +9,14 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; import java.awt.event.MouseMotionListener; import java.awt.image.BufferedImage; +import java.io.BufferedInputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -274,10 +280,92 @@ public class GuiDisplayUtil implements NewConstants { return new ImageIcon(); } + @SuppressWarnings("deprecation") + public static URL getURL(Card c) + { + File dir1 = new File ("."); + + /* + try { + System.out.println ("Current dir : " + dir1.getCanonicalPath()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }*/ + + String path = ""; + try { + path = dir1.getCanonicalPath(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String suffix = ".jpg"; + String filename = ""; + if(!c.isFaceDown()) { + String basicLandSuffix = ""; + if(c.isBasicLand()) { + if(c.getRandomPicture() != 0) { + basicLandSuffix = Integer.toString(c.getRandomPicture()); + //c.setImageName(c.getImageName() + basicLandSuffix); + } + + } + filename = cleanString(c.getImageName())+ basicLandSuffix + suffix; + } else filename = "morph" + suffix; + + String loc = ""; + if (!c.isToken()) + loc = IMAGE_BASE; + else + loc = IMAGE_TOKEN; + + String fileString = path + "\\" +ForgeProps.getFile(loc)+"\\" +filename; + //System.out.println(fileString); + File file = new File(fileString); + + URL url = null; try { url = file.toURL(); return url; } catch (MalformedURLException e) { } + return null; + + } + + public static InputStream getPictureStream(Card c) + { + String suffix = ".jpg"; + String filename = ""; + if(!c.isFaceDown()) { + String basicLandSuffix = ""; + if(c.isBasicLand()) { + if(c.getRandomPicture() != 0) { + basicLandSuffix = Integer.toString(c.getRandomPicture()); + //c.setImageName(c.getImageName() + basicLandSuffix); + } + + } + filename = cleanString(c.getImageName())+ basicLandSuffix + suffix; + } else filename = "morph" + suffix; + + String loc = ""; + if (!c.isToken()) + loc = IMAGE_BASE; + else + loc = IMAGE_TOKEN; + + String fileString = ForgeProps.getFile(loc)+"\\" +filename; + + try { + BufferedInputStream is = new BufferedInputStream(new FileInputStream(fileString)); + return is; + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + public static JPanel getPicture(Card c) { if(AllZone.NameChanger.shouldChangeCardName()) return new JPanel(); - String suffix = ".jpg"; String filename = ""; if(!c.isFaceDown()) { diff --git a/src/forge/Gui_DownloadPictures.java b/src/forge/Gui_DownloadPictures.java index 74f9e0dba58..5f80b13362e 100644 --- a/src/forge/Gui_DownloadPictures.java +++ b/src/forge/Gui_DownloadPictures.java @@ -279,7 +279,11 @@ public class Gui_DownloadPictures extends DefaultBoundedRangeModel implements Ru ErrorViewer.showError(ex, ForgeProps.getLocalized(ERRORS.OTHER), cards[card].name, url); // throw new RuntimeException("Gui_DownloadPictures : error 1 - " +ex); - break; + int more = JOptionPane.showConfirmDialog(null, "Some error occured. Continue downloading pictures?", "Error", + JOptionPane.YES_NO_OPTION); + if (more == JOptionPane.NO_OPTION) { + break; + } } }//for } diff --git a/src/forge/Gui_DownloadPictures_LQ.java b/src/forge/Gui_DownloadPictures_LQ.java index 5619be37aaa..c1f5cb5db47 100644 --- a/src/forge/Gui_DownloadPictures_LQ.java +++ b/src/forge/Gui_DownloadPictures_LQ.java @@ -229,7 +229,11 @@ public class Gui_DownloadPictures_LQ extends DefaultBoundedRangeModel implements ErrorViewer.showError(ex, ForgeProps.getLocalized(ERRORS.OTHER), cards[card].name, cards[card].url); // throw new RuntimeException("Gui_DownloadPictures : error 1 - " +ex); - break; + int more = JOptionPane.showConfirmDialog(null, "Some error occured. Continue downloading pictures?", "Error", + JOptionPane.YES_NO_OPTION); + if (more == JOptionPane.NO_OPTION) { + break; + } } }//for } diff --git a/src/forge/StateBasedEffects.java b/src/forge/StateBasedEffects.java index 616c9889ced..7c9a276d55d 100644 --- a/src/forge/StateBasedEffects.java +++ b/src/forge/StateBasedEffects.java @@ -42,6 +42,7 @@ public class StateBasedEffects cardToEffectsList.put("Terravore", new String[] {"Terravore"}); cardToEffectsList.put("Magnivore", new String[] {"Magnivore"}); cardToEffectsList.put("Tarmogoyf", new String[] {"Tarmogoyf"}); + cardToEffectsList.put("Lhurgoyf", new String[] {"Lhurgoyf"}); cardToEffectsList.put("Drove of Elves", new String[] {"Drove_of_Elves"}); cardToEffectsList.put("Crowd of Cinders", new String[] {"Crowd_of_Cinders"}); cardToEffectsList.put("Faerie Swarm", new String[] {"Faerie_Swarm"}); @@ -49,6 +50,7 @@ public class StateBasedEffects cardToEffectsList.put("Multani, Maro-Sorcerer", new String[] {"Multani_Maro_Sorcerer"}); cardToEffectsList.put("Molimo, Maro-Sorcerer", new String[] {"Molimo_Maro_Sorcerer"}); cardToEffectsList.put("Maro", new String[] {"Maro"}); + cardToEffectsList.put("Overbeing of Myth", new String[] {"Overbeing_of_Myth"}); cardToEffectsList.put("Guul Draz Specter", new String[] {"Guul_Draz_Specter"}); cardToEffectsList.put("Dakkon Blackblade", new String[] {"Dakkon"}); cardToEffectsList.put("Korlash, Heir to Blackblade", new String[] {"Korlash"});