forked from External/mage
Merge
This commit is contained in:
parent
b733f911f7
commit
89dd981075
287 changed files with 3420 additions and 2315 deletions
|
|
@ -96,12 +96,12 @@ public final class Constants {
|
|||
}
|
||||
|
||||
public enum SortBy {
|
||||
|
||||
CARD_TYPE("Card Type"),
|
||||
CASTING_COST("Casting Cost"),
|
||||
RARITY("Rarity"),
|
||||
COLOR("Color"),
|
||||
COLOR_IDENTITY("Color Identity"),
|
||||
NAME("Name"),
|
||||
RARITY("Rarity"),
|
||||
UNSORTED("Unsorted");
|
||||
|
||||
private final String text;
|
||||
|
|
@ -117,6 +117,8 @@ public final class Constants {
|
|||
|
||||
public static SortBy getByString(String text) {
|
||||
switch (text) {
|
||||
case "Card Type":
|
||||
return CARD_TYPE;
|
||||
case "Casting Cost":
|
||||
return CASTING_COST;
|
||||
case "Rarity":
|
||||
|
|
|
|||
|
|
@ -135,6 +135,15 @@ public class DeckArea extends javax.swing.JPanel {
|
|||
hiddenCards.clear();
|
||||
loadDeck(lastDeck, lastBigCard);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void duplicateCards(Collection<CardView> cards) {
|
||||
sideboardList.deselectAll();
|
||||
for (CardView card : cards) {
|
||||
CardView newCard = new CardView(card);
|
||||
deckList.addCardView(newCard, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
sideboardList.addDragCardGridListener(new DragCardGrid.DragCardGridListener() {
|
||||
@Override
|
||||
|
|
@ -156,6 +165,15 @@ public class DeckArea extends javax.swing.JPanel {
|
|||
hiddenCards.clear();
|
||||
loadDeck(lastDeck, lastBigCard);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void duplicateCards(Collection<CardView> cards) {
|
||||
deckList.deselectAll();
|
||||
for (CardView card : cards) {
|
||||
CardView newCard = new CardView(card);
|
||||
sideboardList.addCardView(newCard, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -223,9 +241,8 @@ public class DeckArea extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public void setDeckEditorMode(DeckEditorMode mode) {
|
||||
// Maybe we need this? Right now it isn't needed. Will add if it is.
|
||||
//this.deckList.setDeckEditorMode(mode);
|
||||
//this.sideboardList.setDeckEditorMode(mode);
|
||||
this.deckList.setDeckEditorMode(mode);
|
||||
this.sideboardList.setDeckEditorMode(mode);
|
||||
}
|
||||
|
||||
private Set<Card> filterHidden(Set<Card> cards) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.client.util;
|
||||
|
||||
import java.util.Comparator;
|
||||
import mage.view.CardView;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CardViewCardTypeComparator implements Comparator<CardView> {
|
||||
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
return o1.getCardTypes().toString().compareTo(o2.getCardTypes().toString());
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue