Some fine tuning to enlarged and popup view. Deck editor card size is saved now. Some minor changes.

This commit is contained in:
LevelX2 2016-10-14 17:00:56 +02:00
parent 12e2b0b085
commit fa0fe09192
8 changed files with 183 additions and 131 deletions

View file

@ -11,7 +11,6 @@ import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -666,15 +665,25 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
public Sort sort;
public boolean separateCreatures;
public int cardSize;
private final static Pattern parser = Pattern.compile("\\(([^,]*),([^)]*)\\)");
private final static Pattern parser = Pattern.compile("\\(([^,]*),([^,]*),([^)]*)\\)");
public static Settings parse(String str) {
Matcher m = parser.matcher(str);
if (m.find()) {
Settings s = new Settings();
s.sort = Sort.valueOf(m.group(1));
s.separateCreatures = Boolean.valueOf(m.group(2));
if (m.groupCount() > 0) {
s.sort = Sort.valueOf(m.group(1));
}
if (m.groupCount() > 1) {
s.separateCreatures = Boolean.valueOf(m.group(2));
}
if (m.groupCount() > 2) {
s.cardSize = Integer.valueOf(m.group(3));
} else {
s.cardSize = 50;
}
return s;
} else {
return null;
@ -683,7 +692,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
@Override
public String toString() {
return "(" + sort.toString() + "," + Boolean.toString(separateCreatures) + ")";
return "(" + sort.toString() + "," + Boolean.toString(separateCreatures) + "," + Integer.toString(cardSize) + ")";
}
}
@ -691,6 +700,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
Settings s = new Settings();
s.sort = cardSort;
s.separateCreatures = separateCreatures;
s.cardSize = cardSizeSlider.getValue();
return s;
}
@ -698,6 +708,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
if (s != null) {
setSort(s.sort);
setSeparateCreatures(s.separateCreatures);
setCardSize(s.cardSize);
resort();
}
}
@ -712,6 +723,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
sortButtons.get(s).setSelected(true);
}
public void setCardSize(int size) {
cardSizeSlider.setValue(size);
}
// Constructor
public DragCardGrid() {
// Make sure that the card grid is populated with at least one (empty) stack to begin with
@ -1451,10 +1466,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
cardPanel.setTextOffset(0);
// Remove mouse wheel listeners so that scrolling works
for (MouseWheelListener l : cardPanel.getMouseWheelListeners()) {
cardPanel.removeMouseWheelListener(l);
}
// Scrolling works on all areas without cards or by using the scroll bar, that's enough
// for (MouseWheelListener l : cardPanel.getMouseWheelListeners()) {
// cardPanel.removeMouseWheelListener(l);
// }
// Add a click listener for selection / drag start
cardPanel.addMouseListener(new MouseAdapter() {
@Override

View file

@ -1,12 +1,12 @@
package mage.client.deckeditor;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.*;
public class DeckImportFromClipboardDialog extends JDialog {
@ -24,11 +24,13 @@ public class DeckImportFromClipboardDialog extends JDialog {
getRootPane().setDefaultButton(buttonOK);
buttonOK.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
onOK();
}
});
buttonCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
onCancel();
}
@ -36,6 +38,7 @@ public class DeckImportFromClipboardDialog extends JDialog {
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
onCancel();
}
@ -43,6 +46,7 @@ public class DeckImportFromClipboardDialog extends JDialog {
// Close on "ESC"
contentPane.registerKeyboardAction(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
onCancel();
}
@ -89,8 +93,9 @@ public class DeckImportFromClipboardDialog extends JDialog {
"Import from Clipboard", javax.swing.border.TitledBorder.CENTER,
javax.swing.border.TitledBorder.TOP, new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12),
java.awt.Color.BLACK), contentPane.getBorder()));
contentPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
@Override
public void propertyChange(java.beans.PropertyChangeEvent e) {
if ("border".equals(e.getPropertyName())) {
throw new RuntimeException();
@ -99,6 +104,7 @@ public class DeckImportFromClipboardDialog extends JDialog {
});
contentPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
@Override
public void propertyChange(java.beans.PropertyChangeEvent e) {
if ("border".equals(e.getPropertyName())) {
throw new RuntimeException();

View file

@ -9,6 +9,7 @@ import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -33,7 +34,6 @@ import mage.client.components.MageComponents;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins;
import mage.client.util.DefaultActionCallback;
import mage.client.util.ImageHelper;
import mage.client.util.gui.ArrowBuilder;
import mage.client.util.gui.ArrowUtil;
import mage.client.util.gui.GuiDisplayUtil;
@ -80,6 +80,7 @@ public class MageActionCallback implements ActionCallback {
CLOSED, NORMAL, ROTATED
}
private Date enlargeredViewOpened;
private volatile EnlargedWindowState enlargedWindowState = EnlargedWindowState.CLOSED;
//private volatile boolean enlargedImageWindowOpen = false;
// shows the alternative card the normal card or the alternative card (copy source, other flip side, other transformed side)
@ -115,25 +116,8 @@ public class MageActionCallback implements ActionCallback {
@Override
public void mouseEntered(MouseEvent e, final TransferData data) {
hideTooltipPopup();
cancelTimeout();
this.tooltipCard = data.card;
this.popupData = data;
Component parentComponent = SwingUtilities.getRoot(data.component);
Point parentPoint = parentComponent.getLocationOnScreen();
if (data.locationOnScreen == null) {
data.locationOnScreen = data.component.getLocationOnScreen();
}
ArrowUtil.drawArrowsForTargets(data, parentPoint);
ArrowUtil.drawArrowsForSource(data, parentPoint);
ArrowUtil.drawArrowsForPairedCards(data, parentPoint);
ArrowUtil.drawArrowsForEnchantPlayers(data, parentPoint);
showTooltipPopup(data, parentComponent, parentPoint);
handleOverNewView(data);
}
private void showTooltipPopup(final TransferData data, final Component parentComponent, final Point parentPoint) {
@ -170,7 +154,11 @@ public class MageActionCallback implements ActionCallback {
public void run() {
ThreadUtils.sleep(tooltipDelay);
if (tooltipCard == null || !tooltipCard.equals(data.card) || SessionHandler.getSession() == null || !popupTextWindowOpen || !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
if (tooltipCard == null
|| !tooltipCard.equals(data.card)
|| SessionHandler.getSession() == null
|| !popupTextWindowOpen
|| !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
return;
}
@ -192,7 +180,8 @@ public class MageActionCallback implements ActionCallback {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (!popupTextWindowOpen || !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
if (!popupTextWindowOpen
|| !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
return;
}
if (data.locationOnScreen == null) {
@ -282,6 +271,17 @@ public class MageActionCallback implements ActionCallback {
@Override
public void mouseMoved(MouseEvent e, TransferData transferData) {
if (!Plugins.getInstance().isCardPluginLoaded()) {
return;
}
if (!popupData.card.equals(transferData.card)) {
this.popupData = transferData;
handleOverNewView(transferData);
}
if (bigCard == null) {
return;
}
handlePopup(transferData);
}
@ -376,16 +376,28 @@ public class MageActionCallback implements ActionCallback {
}
}
private void handlePopup(TransferData transferData) {
if (!Plugins.getInstance().isCardPluginLoaded()) {
return;
}
if (bigCard == null) {
return;
private void handleOverNewView(TransferData data) {
hideTooltipPopup();
cancelTimeout();
Component parentComponent = SwingUtilities.getRoot(data.component);
Point parentPoint = parentComponent.getLocationOnScreen();
if (data.locationOnScreen == null) {
data.locationOnScreen = data.component.getLocationOnScreen();
}
ArrowUtil.drawArrowsForTargets(data, parentPoint);
ArrowUtil.drawArrowsForSource(data, parentPoint);
ArrowUtil.drawArrowsForPairedCards(data, parentPoint);
ArrowUtil.drawArrowsForEnchantPlayers(data, parentPoint);
tooltipCard = data.card;
showTooltipPopup(data, parentComponent, parentPoint);
}
private void handlePopup(TransferData transferData) {
MageCard mageCard = (MageCard) transferData.component;
if (!popupTextWindowOpen || mageCard.getOriginal().getId() != bigCard.getCardId()) {
if (!popupTextWindowOpen
|| mageCard.getOriginal().getId() != bigCard.getCardId()) {
if (bigCard.getWidth() > 0) {
synchronized (MageActionCallback.class) {
if (!popupTextWindowOpen || mageCard.getOriginal().getId() != bigCard.getCardId()) {
@ -401,6 +413,7 @@ public class MageActionCallback implements ActionCallback {
popupTextWindowOpen = true;
}
if (!enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
cancelTimeout();
displayEnlargedCard(mageCard.getOriginal(), transferData);
}
}
@ -455,12 +468,18 @@ public class MageActionCallback implements ActionCallback {
int notches = e.getWheelRotation();
if (!enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
// same move direction will be ignored, opposite direction closes the enlarged window
if (enlargeMode.equals(EnlargeMode.NORMAL)) {
if (new Date().getTime() - enlargeredViewOpened.getTime() > 1000) {
// if the opening is back more than 1 seconds close anyway
hideEnlargedCard();
handleOverNewView(transferData);
} else if (enlargeMode.equals(EnlargeMode.NORMAL)) {
if (notches > 0) {
hideEnlargedCard();
handleOverNewView(transferData);
}
} else if (notches < 0) {
hideEnlargedCard();
handleOverNewView(transferData);
}
return;
}
@ -516,7 +535,7 @@ public class MageActionCallback implements ActionCallback {
}
private void displayEnlargedCard(final CardView cardView, final TransferData transferData) {
ThreadUtils.threadPool2.submit(new Runnable() {
ThreadUtils.threadPool3.submit(new Runnable() {
@Override
public void run() {
if (cardView == null) {
@ -608,6 +627,7 @@ public class MageActionCallback implements ActionCallback {
bigCard.hideTextComponent();
bigCard.addJXPanel(mageCard.getOriginal().getId(), panel);
}
enlargeredViewOpened = new Date();
}
private synchronized void startHideTimeout() {

View file

@ -320,6 +320,8 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
/**
* Overridden by different card rendering styles
*
* @param g
*/
protected abstract void paintCard(Graphics2D g);
@ -722,7 +724,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
sb.append("\n").append(card.getLoyalty());
}
if (card.getRules() == null) {
card.overrideRules(new ArrayList<String>());
card.overrideRules(new ArrayList<>());
}
for (String rule : card.getRules()) {
sb.append("\n").append(rule);

View file

@ -28,12 +28,9 @@
package org.mage.plugins.card.dl.sources;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.logging.Level;
import org.apache.log4j.Logger;
import org.mage.plugins.card.images.CardDownloadData;
import org.mage.plugins.card.images.DownloadPictures;
/**
*
@ -54,7 +51,7 @@ public class GrabbagImageSource implements CardImageSource {
@Override
public String getSourceName() {
return "http://magiccards.info/scans/en/" ;
return "http://magiccards.info/scans/en/";
}
@Override
@ -67,9 +64,9 @@ public class GrabbagImageSource implements CardImageSource {
if (copyUrlToImage == null) {
setupLinks();
}
try {
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
} catch (InterruptedException ex) {
}
for (String key : copyUrlToImageDone.keySet()) {
@ -114,29 +111,29 @@ public class GrabbagImageSource implements CardImageSource {
if (copyUrlToImage != null) {
return;
}
copyUrlToImage = new HashMap<String, String>();
copyImageToUrl = new HashMap<String, String>();
copyUrlToImageDone = new HashMap<String, Integer>();
copyUrlToImage = new HashMap<>();
copyImageToUrl = new HashMap<>();
copyUrlToImageDone = new HashMap<>();
//http://anonymouse.org/cgi-bin/anon-www.cgi/http://magiccards.info/scans/en/arena/42.jpg
copyUrlToImage.put("apac/1.jpg", "APAC.zip/APAC/Forest 3.full.jpg");
copyUrlToImage.put("apac/10.jpg", "APAC.zip/APAC/Swamp.5.full.jpg");
copyUrlToImage.put("apac/10.jpg", "APAC.zip/APAC/Swamp.5.full.jpg");
copyUrlToImage.put("apac/11.jpg", "APAC.zip/APAC/Forest 2.full.jpg");
copyUrlToImage.put("apac/12.jpg", "APAC.zip/APAC/Island.7.full.jpg");
copyUrlToImage.put("apac/13.jpg", "APAC.zip/APAC/Mountain.8.full.jpg");
copyUrlToImage.put("apac/14.jpg", "APAC.zip/APAC/Plains.4.full.jpg");
copyUrlToImage.put("apac/12.jpg", "APAC.zip/APAC/Island.7.full.jpg");
copyUrlToImage.put("apac/13.jpg", "APAC.zip/APAC/Mountain.8.full.jpg");
copyUrlToImage.put("apac/14.jpg", "APAC.zip/APAC/Plains.4.full.jpg");
copyUrlToImage.put("apac/15.jpg", "APAC.zip/APAC/Swamp 2.full.jpg");
copyUrlToImage.put("apac/15.jpg", "APAC.zip/APAC/Swamp.15.full.jpg");
copyUrlToImage.put("apac/2.jpg", "APAC.zip/APAC/Island 2.full.jpg");
copyUrlToImage.put("apac/2.jpg", "APAC.zip/APAC/Island.2.full.jpg");
copyUrlToImage.put("apac/3.jpg", "APAC.zip/APAC/Mountain.3.full.jpg");
copyUrlToImage.put("apac/3.jpg", "APAC.zip/APAC/Mountain.3.full.jpg");
copyUrlToImage.put("apac/4.jpg", "APAC.zip/APAC/Plains 2.full.jpg");
copyUrlToImage.put("apac/4.jpg", "APAC.zip/APAC/Plains.9.full.jpg");
copyUrlToImage.put("apac/5.jpg", "APAC.zip/APAC/Swamp.10.full.jpg");
copyUrlToImage.put("apac/5.jpg", "APAC.zip/APAC/Swamp.10.full.jpg");
copyUrlToImage.put("apac/6.jpg", "APAC.zip/APAC/Forest 1.full.jpg");
copyUrlToImage.put("apac/7.jpg", "APAC.zip/APAC/Island.12.full.jpg");
copyUrlToImage.put("apac/8.jpg", "APAC.zip/APAC/Mountain.13.full.jpg");
copyUrlToImage.put("apac/9.jpg", "APAC.zip/APAC/Plains.14.full.jpg");
copyUrlToImage.put("apac/7.jpg", "APAC.zip/APAC/Island.12.full.jpg");
copyUrlToImage.put("apac/8.jpg", "APAC.zip/APAC/Mountain.13.full.jpg");
copyUrlToImage.put("apac/9.jpg", "APAC.zip/APAC/Plains.14.full.jpg");
copyUrlToImage.put("arena/1.jpg", "ARENA.zip/ARENA/Plains 8.full.jpg");
copyUrlToImage.put("arena/1.jpg", "ARENA.zip/ARENA/Plains.1.full.jpg");
copyUrlToImage.put("arena/10.jpg", "ARENA.zip/ARENA/Swamp 8.full.jpg");
@ -156,25 +153,25 @@ public class GrabbagImageSource implements CardImageSource {
copyUrlToImage.put("arena/20.jpg", "ARENA.zip/ARENA/Pillage.full.jpg");
copyUrlToImage.put("arena/21.jpg", "ARENA.zip/ARENA/Enlightened Tutor.full.jpg");
copyUrlToImage.put("arena/22.jpg", "ARENA.zip/ARENA/Stupor.full.jpg");
copyUrlToImage.put("arena/23.jpg", "ARENA.zip/ARENA/Plains.75.full.jpg");
copyUrlToImage.put("arena/24.jpg", "ARENA.zip/ARENA/Island.9.full.jpg");
copyUrlToImage.put("arena/25.jpg", "ARENA.zip/ARENA/Swamp.77.full.jpg");
copyUrlToImage.put("arena/26.jpg", "ARENA.zip/ARENA/Mountain.70.full.jpg");
copyUrlToImage.put("arena/23.jpg", "ARENA.zip/ARENA/Plains.75.full.jpg");
copyUrlToImage.put("arena/24.jpg", "ARENA.zip/ARENA/Island.9.full.jpg");
copyUrlToImage.put("arena/25.jpg", "ARENA.zip/ARENA/Swamp.77.full.jpg");
copyUrlToImage.put("arena/26.jpg", "ARENA.zip/ARENA/Mountain.70.full.jpg");
copyUrlToImage.put("arena/27.jpg", "ARENA.zip/ARENA/Forest 8.full.jpg");
copyUrlToImage.put("arena/28.jpg", "ARENA.zip/ARENA/Creeping Mold.full.jpg");
copyUrlToImage.put("arena/29.jpg", "ARENA.zip/ARENA/Dismiss.full.jpg");
copyUrlToImage.put("arena/3.jpg", "ARENA.zip/ARENA/Swamp.69.full.jpg");
copyUrlToImage.put("arena/3.jpg", "ARENA.zip/ARENA/Swamp.69.full.jpg");
copyUrlToImage.put("arena/30.jpg", "ARENA.zip/ARENA/Fling.full.jpg");
copyUrlToImage.put("arena/31.jpg", "ARENA.zip/ARENA/Empyrial Armor.full.jpg");
copyUrlToImage.put("arena/32.jpg", "ARENA.zip/ARENA/Plains.67.full.jpg");
copyUrlToImage.put("arena/33.jpg", "ARENA.zip/ARENA/Island.76.full.jpg");
copyUrlToImage.put("arena/34.jpg", "ARENA.zip/ARENA/Swamp.55.full.jpg");
copyUrlToImage.put("arena/32.jpg", "ARENA.zip/ARENA/Plains.67.full.jpg");
copyUrlToImage.put("arena/33.jpg", "ARENA.zip/ARENA/Island.76.full.jpg");
copyUrlToImage.put("arena/34.jpg", "ARENA.zip/ARENA/Swamp.55.full.jpg");
copyUrlToImage.put("arena/35.jpg", "ARENA.zip/ARENA/Mountain 6.full.jpg");
copyUrlToImage.put("arena/35.jpg", "ARENA.zip/ARENA/Mountain.78.full.jpg");
copyUrlToImage.put("arena/36.jpg", "ARENA.zip/ARENA/Forest.71.full.jpg");
copyUrlToImage.put("arena/36.jpg", "ARENA.zip/ARENA/Forest.71.full.jpg");
copyUrlToImage.put("arena/37.jpg", "ARENA.zip/ARENA/Diabolic Edict.full.jpg");
copyUrlToImage.put("arena/38.jpg", "ARENA.zip/ARENA/Gaea's Blessing.full.jpg");
copyUrlToImage.put("arena/39.jpg", "ARENA.zip/ARENA/Island.68.full.jpg");
copyUrlToImage.put("arena/39.jpg", "ARENA.zip/ARENA/Island.68.full.jpg");
copyUrlToImage.put("arena/4.jpg", "ARENA.zip/ARENA/Mountain 5.full.jpg");
copyUrlToImage.put("arena/40.jpg", "ARENA.zip/ARENA/Forest 6.full.jpg");
copyUrlToImage.put("arena/40.jpg", "ARENA.zip/ARENA/Forest.5.full.jpg");
@ -182,20 +179,20 @@ public class GrabbagImageSource implements CardImageSource {
copyUrlToImage.put("arena/42.jpg", "ARENA.zip/ARENA/Arc Lightning.full.jpg");
copyUrlToImage.put("arena/43.jpg", "ARENA.zip/ARENA/Dauthi Slayer.full.jpg");
copyUrlToImage.put("arena/44.jpg", "ARENA.zip/ARENA/Mana Leak.full.jpg");
copyUrlToImage.put("arena/45.jpg", "ARENA.zip/ARENA/Plains.53.full.jpg");
copyUrlToImage.put("arena/46.jpg", "ARENA.zip/ARENA/Island.54.full.jpg");
copyUrlToImage.put("arena/47.jpg", "ARENA.zip/ARENA/Swamp.47.full.jpg");
copyUrlToImage.put("arena/48.jpg", "ARENA.zip/ARENA/Mountain.48.full.jpg");
copyUrlToImage.put("arena/49.jpg", "ARENA.zip/ARENA/Forest.57.full.jpg");
copyUrlToImage.put("arena/5.jpg", "ARENA.zip/ARENA/Forest.40.full.jpg");
copyUrlToImage.put("arena/45.jpg", "ARENA.zip/ARENA/Plains.53.full.jpg");
copyUrlToImage.put("arena/46.jpg", "ARENA.zip/ARENA/Island.54.full.jpg");
copyUrlToImage.put("arena/47.jpg", "ARENA.zip/ARENA/Swamp.47.full.jpg");
copyUrlToImage.put("arena/48.jpg", "ARENA.zip/ARENA/Mountain.48.full.jpg");
copyUrlToImage.put("arena/49.jpg", "ARENA.zip/ARENA/Forest.57.full.jpg");
copyUrlToImage.put("arena/5.jpg", "ARENA.zip/ARENA/Forest.40.full.jpg");
copyUrlToImage.put("arena/50.jpg", "ARENA.zip/ARENA/Skirk Marauder.full.jpg");
copyUrlToImage.put("arena/51.jpg", "ARENA.zip/ARENA/Elvish Aberration.full.jpg");
copyUrlToImage.put("arena/52.jpg", "ARENA.zip/ARENA/Bonesplitter.full.jpg");
copyUrlToImage.put("arena/53.jpg", "ARENA.zip/ARENA/Plains.45.full.jpg");
copyUrlToImage.put("arena/54.jpg", "ARENA.zip/ARENA/Island.46.full.jpg");
copyUrlToImage.put("arena/55.jpg", "ARENA.zip/ARENA/Swamp.34.full.jpg");
copyUrlToImage.put("arena/56.jpg", "ARENA.zip/ARENA/Mountain.35.full.jpg");
copyUrlToImage.put("arena/57.jpg", "ARENA.zip/ARENA/Forest.36.full.jpg");
copyUrlToImage.put("arena/53.jpg", "ARENA.zip/ARENA/Plains.45.full.jpg");
copyUrlToImage.put("arena/54.jpg", "ARENA.zip/ARENA/Island.46.full.jpg");
copyUrlToImage.put("arena/55.jpg", "ARENA.zip/ARENA/Swamp.34.full.jpg");
copyUrlToImage.put("arena/56.jpg", "ARENA.zip/ARENA/Mountain.35.full.jpg");
copyUrlToImage.put("arena/57.jpg", "ARENA.zip/ARENA/Forest.36.full.jpg");
copyUrlToImage.put("arena/58.jpg", "ARENA.zip/ARENA/Darksteel Ingot.full.jpg");
copyUrlToImage.put("arena/59.jpg", "ARENA.zip/ARENA/Serum Visions.full.jpg");
copyUrlToImage.put("arena/6.jpg", "ARENA.zip/ARENA/Disenchant.full.jpg");
@ -206,46 +203,46 @@ public class GrabbagImageSource implements CardImageSource {
copyUrlToImage.put("arena/64.jpg", "ARENA.zip/ARENA/Goblin Mime.full.jpg");
copyUrlToImage.put("arena/65.jpg", "ARENA.zip/ARENA/Granny's Payback.full.jpg");
copyUrlToImage.put("arena/66.jpg", "ARENA.zip/ARENA/Ashnod's Coupon.full.jpg");
copyUrlToImage.put("arena/67.jpg", "ARENA.zip/ARENA/Plains.32.full.jpg");
copyUrlToImage.put("arena/68.jpg", "ARENA.zip/ARENA/Island.33.full.jpg");
copyUrlToImage.put("arena/69.jpg", "ARENA.zip/ARENA/Swamp.25.full.jpg");
copyUrlToImage.put("arena/67.jpg", "ARENA.zip/ARENA/Plains.32.full.jpg");
copyUrlToImage.put("arena/68.jpg", "ARENA.zip/ARENA/Island.33.full.jpg");
copyUrlToImage.put("arena/69.jpg", "ARENA.zip/ARENA/Swamp.25.full.jpg");
copyUrlToImage.put("arena/7.jpg", "ARENA.zip/ARENA/Fireball.full.jpg");
copyUrlToImage.put("arena/70.jpg", "ARENA.zip/ARENA/Mountain.26.full.jpg");
copyUrlToImage.put("arena/71.jpg", "ARENA.zip/ARENA/Forest.27.full.jpg");
copyUrlToImage.put("arena/70.jpg", "ARENA.zip/ARENA/Mountain.26.full.jpg");
copyUrlToImage.put("arena/71.jpg", "ARENA.zip/ARENA/Forest.27.full.jpg");
copyUrlToImage.put("arena/72.jpg", "ARENA.zip/ARENA/Genju of the Spires.full.jpg");
copyUrlToImage.put("arena/73.jpg", "ARENA.zip/ARENA/Okina Nightwatch.full.jpg");
copyUrlToImage.put("arena/74.jpg", "ARENA.zip/ARENA/Skyknight Legionnaire.full.jpg");
copyUrlToImage.put("arena/75.jpg", "ARENA.zip/ARENA/Plains.23.full.jpg");
copyUrlToImage.put("arena/76.jpg", "ARENA.zip/ARENA/Island.24.full.jpg");
copyUrlToImage.put("arena/77.jpg", "ARENA.zip/ARENA/Swamp.10.full.jpg");
copyUrlToImage.put("arena/78.jpg", "ARENA.zip/ARENA/Mountain.11.full.jpg");
copyUrlToImage.put("arena/79.jpg", "ARENA.zip/ARENA/Forest.12.full.jpg");
copyUrlToImage.put("arena/75.jpg", "ARENA.zip/ARENA/Plains.23.full.jpg");
copyUrlToImage.put("arena/76.jpg", "ARENA.zip/ARENA/Island.24.full.jpg");
copyUrlToImage.put("arena/77.jpg", "ARENA.zip/ARENA/Swamp.10.full.jpg");
copyUrlToImage.put("arena/78.jpg", "ARENA.zip/ARENA/Mountain.11.full.jpg");
copyUrlToImage.put("arena/79.jpg", "ARENA.zip/ARENA/Forest.12.full.jpg");
copyUrlToImage.put("arena/8.jpg", "ARENA.zip/ARENA/Plains 1.full.jpg");
copyUrlToImage.put("arena/8.jpg", "ARENA.zip/ARENA/Plains.8.full.jpg");
copyUrlToImage.put("arena/80.jpg", "ARENA.zip/ARENA/Castigate.full.jpg");
copyUrlToImage.put("arena/81.jpg", "ARENA.zip/ARENA/Wee Dragonauts.full.jpg");
copyUrlToImage.put("arena/82.jpg", "ARENA.zip/ARENA/Coiling Oracle.full.jpg");
copyUrlToImage.put("arena/83.jpg", "ARENA.zip/ARENA/Surging Flame.full.jpg");
copyUrlToImage.put("arena/9.jpg", "ARENA.zip/ARENA/Island.2.full.jpg");
copyUrlToImage.put("euro/1.jpg", "EURO.zip/EURO/Forest.6.full.jpg");
copyUrlToImage.put("euro/10.jpg", "EURO.zip/EURO/Swamp.5.full.jpg");
copyUrlToImage.put("arena/9.jpg", "ARENA.zip/ARENA/Island.2.full.jpg");
copyUrlToImage.put("euro/1.jpg", "EURO.zip/EURO/Forest.6.full.jpg");
copyUrlToImage.put("euro/10.jpg", "EURO.zip/EURO/Swamp.5.full.jpg");
copyUrlToImage.put("euro/11.jpg", "EURO.zip/EURO/Forest 2.full.jpg");
copyUrlToImage.put("euro/11.jpg", "EURO.zip/EURO/Forest.1.full.jpg");
copyUrlToImage.put("euro/12.jpg", "EURO.zip/EURO/Island.7.full.jpg");
copyUrlToImage.put("euro/13.jpg", "EURO.zip/EURO/Mountain.8.full.jpg");
copyUrlToImage.put("euro/14.jpg", "EURO.zip/EURO/Plains.4.full.jpg");
copyUrlToImage.put("euro/12.jpg", "EURO.zip/EURO/Island.7.full.jpg");
copyUrlToImage.put("euro/13.jpg", "EURO.zip/EURO/Mountain.8.full.jpg");
copyUrlToImage.put("euro/14.jpg", "EURO.zip/EURO/Plains.4.full.jpg");
copyUrlToImage.put("euro/15.jpg", "EURO.zip/EURO/Swamp 2.full.jpg");
copyUrlToImage.put("euro/15.jpg", "EURO.zip/EURO/Swamp.15.full.jpg");
copyUrlToImage.put("euro/2.jpg", "EURO.zip/EURO/Island 2.full.jpg");
copyUrlToImage.put("euro/2.jpg", "EURO.zip/EURO/Island.2.full.jpg");
copyUrlToImage.put("euro/3.jpg", "EURO.zip/EURO/Mountain.3.full.jpg");
copyUrlToImage.put("euro/3.jpg", "EURO.zip/EURO/Mountain.3.full.jpg");
copyUrlToImage.put("euro/4.jpg", "EURO.zip/EURO/Plains 2.full.jpg");
copyUrlToImage.put("euro/4.jpg", "EURO.zip/EURO/Plains.9.full.jpg");
copyUrlToImage.put("euro/5.jpg", "EURO.zip/EURO/Swamp.10.full.jpg");
copyUrlToImage.put("euro/6.jpg", "EURO.zip/EURO/Forest.11.full.jpg");
copyUrlToImage.put("euro/7.jpg", "EURO.zip/EURO/Island.12.full.jpg");
copyUrlToImage.put("euro/8.jpg", "EURO.zip/EURO/Mountain.13.full.jpg");
copyUrlToImage.put("euro/9.jpg", "EURO.zip/EURO/Plains.14.full.jpg");
copyUrlToImage.put("euro/5.jpg", "EURO.zip/EURO/Swamp.10.full.jpg");
copyUrlToImage.put("euro/6.jpg", "EURO.zip/EURO/Forest.11.full.jpg");
copyUrlToImage.put("euro/7.jpg", "EURO.zip/EURO/Island.12.full.jpg");
copyUrlToImage.put("euro/8.jpg", "EURO.zip/EURO/Mountain.13.full.jpg");
copyUrlToImage.put("euro/9.jpg", "EURO.zip/EURO/Plains.14.full.jpg");
copyUrlToImage.put("exp/1.jpg", "EXP.zip/EXP/Prairie Stream.full.jpg");
copyUrlToImage.put("exp/10.jpg", "EXP.zip/EXP/Temple Garden.full.jpg");
copyUrlToImage.put("exp/11.jpg", "EXP.zip/EXP/Godless Shrine.full.jpg");
@ -1246,9 +1243,7 @@ public class GrabbagImageSource implements CardImageSource {
copyUrlToImage.put("mbp/145.jpg", "MBP.zip/MBP/Dread Defiler.full.jpg");
copyUrlToImage.put("mbp/146.jpg", "MBP.zip/MBP/Tyrant of Valakut.full.jpg");
copyUrlToImage.put("mbp/147.jpg", "MBP.zip/MBP/Gladehart Cavalry.full.jpg");
copyUrlToImage.put("mbp/148.jpg", "MBP.zip/MBP/Goblin Dark-Dwellers.full.jpg");
copyUrlToImage.put("mbp/148.jpg", "MBP.zip/MBP/Goblin Dark-Dwellers.full.jpg");
for (String key : copyUrlToImage.keySet()) {
copyUrlToImageDone.put(key, maxTimes);
@ -1271,7 +1266,7 @@ public class GrabbagImageSource implements CardImageSource {
}
return -1;
}
@Override
public Boolean isTokenSource() {
return false;

View file

@ -23,7 +23,6 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -57,11 +56,11 @@ import net.java.truevfs.access.TFileOutputStream;
import net.java.truevfs.access.TVFS;
import net.java.truevfs.kernel.spec.FsSyncException;
import org.apache.log4j.Logger;
import org.mage.plugins.card.dl.sources.AltMtgOnlTokensImageSource;
import org.mage.plugins.card.dl.sources.CardImageSource;
import org.mage.plugins.card.dl.sources.GrabbagImageSource;
import org.mage.plugins.card.dl.sources.MagicCardsImageSource;
import org.mage.plugins.card.dl.sources.MtgOnlTokensImageSource;
import org.mage.plugins.card.dl.sources.AltMtgOnlTokensImageSource;
import org.mage.plugins.card.dl.sources.GrabbagImageSource;
import org.mage.plugins.card.dl.sources.MythicspoilerComSource;
import org.mage.plugins.card.dl.sources.TokensMtgImageSource;
import org.mage.plugins.card.dl.sources.WizardCardsImageSource;
@ -183,10 +182,10 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
break;
case 5:
cardImageSource = AltMtgOnlTokensImageSource.getInstance();
break;
break;
case 6:
cardImageSource = GrabbagImageSource.getInstance();
break;
break;
}
int count = DownloadPictures.this.cards.size();
float mb = (count * cardImageSource.getAverageSize()) / 1024;
@ -565,7 +564,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
private final URL url;
private final int count;
private final String actualFilename;
private boolean useSpecifiedPaths;
private final boolean useSpecifiedPaths;
public DownloadTask(CardDownloadData card, URL url, int count) {
this.card = card;
@ -597,17 +596,15 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
String imagePath;
if (useSpecifiedPaths) {
if (card != null && card.isToken()) {
imagePath = CardImageUtils.getTokenBasePath() + actualFilename;;
imagePath = CardImageUtils.getTokenBasePath() + actualFilename;
} else if (card != null) {
imagePath = CardImageUtils.getImageBasePath() + actualFilename;
} else {
if (card != null) {
imagePath = CardImageUtils.getImageBasePath() + actualFilename;
} else {
imagePath = Constants.IO.imageBaseDir;
}
imagePath = Constants.IO.imageBaseDir;
}
String tmpFile = filePath + "temporary" + actualFilename;
temporaryFile = new File(tmpFile.toString());
temporaryFile = new File(tmpFile);
if (!temporaryFile.exists()) {
temporaryFile.getParentFile().mkdirs();
}

View file

@ -15,14 +15,17 @@ public class ThreadUtils {
public static final ThreadPoolExecutor threadPool;
public static final ThreadPoolExecutor threadPool2;
public static final ThreadPoolExecutor threadPool3;
private static int threadCount;
static {
/** used in CardInfoPaneImpl
*
/**
* used in CardInfoPaneImpl
*
*/
threadPool = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
@Override
public Thread newThread (Runnable runnable) {
public Thread newThread(Runnable runnable) {
threadCount++;
Thread thread = new Thread(runnable, "Util" + threadCount);
thread.setDaemon(true);
@ -30,13 +33,13 @@ public class ThreadUtils {
}
});
threadPool.prestartAllCoreThreads();
/**
* Used for MageActionCallback
* Used for MageActionCallback
*/
threadPool2 = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
@Override
public Thread newThread (Runnable runnable) {
public Thread newThread(Runnable runnable) {
threadCount++;
Thread thread = new Thread(runnable, "TP2" + threadCount);
thread.setDaemon(true);
@ -44,16 +47,30 @@ public class ThreadUtils {
}
});
threadPool2.prestartAllCoreThreads();
/**
* Used for Enlarged view
*/
threadPool3 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
@Override
public Thread newThread(Runnable runnable) {
threadCount++;
Thread thread = new Thread(runnable, "EV" + threadCount);
thread.setDaemon(true);
return thread;
}
});
threadPool3.prestartAllCoreThreads();
}
public static void sleep (int millis) {
public static void sleep(int millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException ignored) {
}
}
public static void wait (Object lock) {
public static void wait(Object lock) {
synchronized (lock) {
try {
lock.wait();

View file

@ -93,7 +93,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
// cards in Graveyard
int cardsCount = (cardName.isEmpty() ? 0 : targetPlayer.getGraveyard().count(filter, game));
if (cardsCount > 0) {
filter.setMessage("card named " + cardName + " in the graveyard of " + targetPlayer.getLogName());
filter.setMessage("card named " + cardName + " in the graveyard of " + targetPlayer.getName());
TargetCard target = new TargetCard((graveyardExileOptional ? 0 : cardsCount), cardsCount, Zone.GRAVEYARD, filter);
if (controller.choose(Outcome.Exile, targetPlayer.getGraveyard(), target, game)) {
controller.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game);
@ -102,7 +102,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
// cards in Hand
cardsCount = (cardName.isEmpty() ? 0 : targetPlayer.getHand().count(filter, game));
filter.setMessage("card named " + cardName + " in the hand of " + targetPlayer.getLogName());
filter.setMessage("card named " + cardName + " in the hand of " + targetPlayer.getName());
TargetCard target = new TargetCard(0, cardsCount, Zone.HAND, filter);
if (controller.choose(Outcome.Exile, targetPlayer.getHand(), target, game)) {
controller.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game);