mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
UI: improved card render test dialog (added render mode and size choose);
This commit is contained in:
parent
998044068d
commit
c45f64bdec
18 changed files with 1710 additions and 1547 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package mage.client.cards;
|
package mage.client.cards;
|
||||||
|
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.ClientEventType;
|
import mage.client.util.ClientEventType;
|
||||||
import mage.client.util.Event;
|
import mage.client.util.Event;
|
||||||
|
|
@ -30,6 +31,9 @@ public class CardArea extends JPanel implements MouseListener {
|
||||||
private Dimension cardDimension;
|
private Dimension cardDimension;
|
||||||
private int verticalCardOffset;
|
private int verticalCardOffset;
|
||||||
|
|
||||||
|
private int customRenderMode = -1; // custom render mode tests
|
||||||
|
private Dimension customCardSize = null; // custom size for tests
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the panel.
|
* Create the panel.
|
||||||
*/
|
*/
|
||||||
|
|
@ -62,7 +66,11 @@ public class CardArea extends JPanel implements MouseListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setGUISize() {
|
private void setGUISize() {
|
||||||
setCardDimension(GUISizeHelper.otherZonesCardDimension, GUISizeHelper.otherZonesCardVerticalOffset);
|
if (customCardSize != null) {
|
||||||
|
setCardDimension(customCardSize, GUISizeHelper.otherZonesCardVerticalOffset);
|
||||||
|
} else {
|
||||||
|
setCardDimension(GUISizeHelper.otherZonesCardDimension, GUISizeHelper.otherZonesCardVerticalOffset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCardDimension(Dimension dimension, int verticalCardOffset) {
|
public void setCardDimension(Dimension dimension, int verticalCardOffset) {
|
||||||
|
|
@ -129,7 +137,8 @@ public class CardArea extends JPanel implements MouseListener {
|
||||||
tmp.setAbility(card); // cross-reference, required for ability picker
|
tmp.setAbility(card); // cross-reference, required for ability picker
|
||||||
card = tmp;
|
card = tmp;
|
||||||
}
|
}
|
||||||
MageCard cardPanel = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true);
|
MageCard cardPanel = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true,
|
||||||
|
customRenderMode != -1 ? customRenderMode : PreferencesDialog.getRenderMode());
|
||||||
|
|
||||||
cardPanel.setBounds(rectangle);
|
cardPanel.setBounds(rectangle);
|
||||||
cardPanel.addMouseListener(this);
|
cardPanel.addMouseListener(this);
|
||||||
|
|
@ -265,6 +274,14 @@ public class CardArea extends JPanel implements MouseListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCustomRenderMode(int customRenderMode) {
|
||||||
|
this.customRenderMode = customRenderMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomCardSize(Dimension customCardSize) {
|
||||||
|
this.customCardSize = customCardSize;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(MouseEvent e) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package mage.client.cards;
|
||||||
|
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
import mage.client.MagePane;
|
import mage.client.MagePane;
|
||||||
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
|
|
||||||
|
|
@ -45,7 +46,7 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
|
||||||
currentRoot = SwingUtilities.getRootPane(c);
|
currentRoot = SwingUtilities.getRootPane(c);
|
||||||
|
|
||||||
// Pane
|
// Pane
|
||||||
glassPane = (JComponent)currentRoot.getGlassPane();
|
glassPane = (JComponent) currentRoot.getGlassPane();
|
||||||
glassPane.setLayout(null);
|
glassPane.setLayout(null);
|
||||||
glassPane.setOpaque(false);
|
glassPane.setOpaque(false);
|
||||||
glassPane.setVisible(true);
|
glassPane.setVisible(true);
|
||||||
|
|
@ -58,7 +59,7 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
|
||||||
if (rootMagePane == null) {
|
if (rootMagePane == null) {
|
||||||
throw new RuntimeException("CardDraggerGlassPane::beginDrag not in a MagePane?");
|
throw new RuntimeException("CardDraggerGlassPane::beginDrag not in a MagePane?");
|
||||||
} else {
|
} else {
|
||||||
currentEventRootMagePane = (MagePane)rootMagePane;
|
currentEventRootMagePane = (MagePane) rootMagePane;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hook up events
|
// Hook up events
|
||||||
|
|
@ -72,8 +73,8 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
|
||||||
currentCards = new ArrayList<>(source.dragCardList());
|
currentCards = new ArrayList<>(source.dragCardList());
|
||||||
|
|
||||||
// Make a view for the first one and add it to us
|
// Make a view for the first one and add it to us
|
||||||
dragView = Plugins.instance.getMageCard(currentCards.get(0), null, new Dimension(100, 140), null, true, false);
|
dragView = Plugins.instance.getMageCard(currentCards.get(0), null, new Dimension(100, 140), null, true, false, PreferencesDialog.getRenderMode());
|
||||||
for (MouseListener l: dragView.getMouseListeners()) {
|
for (MouseListener l : dragView.getMouseListeners()) {
|
||||||
dragView.removeMouseListener(l);
|
dragView.removeMouseListener(l);
|
||||||
}
|
}
|
||||||
for (MouseMotionListener l : dragView.getMouseMotionListeners()) {
|
for (MouseMotionListener l : dragView.getMouseMotionListeners()) {
|
||||||
|
|
@ -95,7 +96,7 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
|
||||||
Component mouseOver = SwingUtilities.getDeepestComponentAt(currentEventRootMagePane, e.getX(), e.getY());
|
Component mouseOver = SwingUtilities.getDeepestComponentAt(currentEventRootMagePane, e.getX(), e.getY());
|
||||||
while (mouseOver != null) {
|
while (mouseOver != null) {
|
||||||
if (mouseOver instanceof DragCardTarget) {
|
if (mouseOver instanceof DragCardTarget) {
|
||||||
DragCardTarget target = (DragCardTarget)mouseOver;
|
DragCardTarget target = (DragCardTarget) mouseOver;
|
||||||
MouseEvent targetEvent = SwingUtilities.convertMouseEvent(currentEventRootMagePane, e, mouseOver);
|
MouseEvent targetEvent = SwingUtilities.convertMouseEvent(currentEventRootMagePane, e, mouseOver);
|
||||||
if (target != currentDragTarget) {
|
if (target != currentDragTarget) {
|
||||||
if (currentDragTarget != null) {
|
if (currentDragTarget != null) {
|
||||||
|
|
@ -116,7 +117,7 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
|
||||||
mouseOver = mouseOver.getParent();
|
mouseOver = mouseOver.getParent();
|
||||||
}
|
}
|
||||||
if (currentDragTarget != null) {
|
if (currentDragTarget != null) {
|
||||||
MouseEvent oldTargetEvent = SwingUtilities.convertMouseEvent(currentEventRootMagePane, e, (Component)currentDragTarget);
|
MouseEvent oldTargetEvent = SwingUtilities.convertMouseEvent(currentEventRootMagePane, e, (Component) currentDragTarget);
|
||||||
currentDragTarget.dragCardExit(oldTargetEvent);
|
currentDragTarget.dragCardExit(oldTargetEvent);
|
||||||
}
|
}
|
||||||
currentDragTarget = null;
|
currentDragTarget = null;
|
||||||
|
|
@ -164,13 +165,22 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {}
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent e) {}
|
public void mousePressed(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent e) {}
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e) {}
|
public void mouseExited(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseMoved(MouseEvent e) {}
|
public void mouseMoved(MouseEvent e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,430 +1,430 @@
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CardGrid.java
|
* CardGrid.java
|
||||||
*
|
*
|
||||||
* Created on 30-Mar-2010, 9:25:40 PM
|
* Created on 30-Mar-2010, 9:25:40 PM
|
||||||
*/
|
*/
|
||||||
package mage.client.cards;
|
package mage.client.cards;
|
||||||
|
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
import mage.client.deckeditor.SortSetting;
|
import mage.client.deckeditor.SortSetting;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import mage.client.util.ClientEventType;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.Event;
|
import mage.client.util.ClientEventType;
|
||||||
import mage.client.util.GUISizeHelper;
|
import mage.client.util.Event;
|
||||||
import mage.client.util.Listener;
|
import mage.client.util.GUISizeHelper;
|
||||||
import mage.utils.CardColorUtil;
|
import mage.client.util.Listener;
|
||||||
import mage.view.CardView;
|
import mage.utils.CardColorUtil;
|
||||||
import mage.view.CardsView;
|
import mage.view.CardView;
|
||||||
import org.mage.card.arcane.CardPanel;
|
import mage.view.CardsView;
|
||||||
|
import org.mage.card.arcane.CardPanel;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author BetaSteward_at_googlemail.com
|
||||||
* @author BetaSteward_at_googlemail.com
|
*/
|
||||||
*/
|
public class CardGrid extends javax.swing.JLayeredPane implements MouseListener, ICardGrid {
|
||||||
public class CardGrid extends javax.swing.JLayeredPane implements MouseListener, ICardGrid {
|
|
||||||
|
|
||||||
protected final CardEventSource cardEventSource = new CardEventSource();
|
protected final CardEventSource cardEventSource = new CardEventSource();
|
||||||
protected BigCard bigCard;
|
protected BigCard bigCard;
|
||||||
protected UUID gameId;
|
protected UUID gameId;
|
||||||
private final Map<UUID, MageCard> cards = new HashMap<>();
|
private final Map<UUID, MageCard> cards = new HashMap<>();
|
||||||
private Dimension cardDimension;
|
private Dimension cardDimension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Max amount of cards in card grid for which card images will be drawn.
|
* Max amount of cards in card grid for which card images will be drawn.
|
||||||
* Done so to solve issue with memory for big piles of cards.
|
* Done so to solve issue with memory for big piles of cards.
|
||||||
*/
|
*/
|
||||||
public static final int MAX_IMAGES = 350;
|
public static final int MAX_IMAGES = 350;
|
||||||
|
|
||||||
public CardGrid() {
|
public CardGrid() {
|
||||||
initComponents();
|
initComponents();
|
||||||
setGUISize();
|
setGUISize();
|
||||||
setOpaque(false);
|
setOpaque(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
for (MouseListener ml : this.getMouseListeners()) {
|
for (MouseListener ml : this.getMouseListeners()) {
|
||||||
this.removeMouseListener(ml);
|
this.removeMouseListener(ml);
|
||||||
}
|
}
|
||||||
this.clearCardEventListeners();
|
this.clearCardEventListeners();
|
||||||
this.clearCards();
|
this.clearCards();
|
||||||
this.bigCard = null;
|
this.bigCard = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeGUISize() {
|
public void changeGUISize() {
|
||||||
setGUISize();
|
setGUISize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setGUISize() {
|
private void setGUISize() {
|
||||||
cardDimension = GUISizeHelper.editorCardDimension;
|
cardDimension = GUISizeHelper.editorCardDimension;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadCards(CardsView showCards, SortSetting sortSetting, BigCard bigCard, UUID gameId) {
|
public void loadCards(CardsView showCards, SortSetting sortSetting, BigCard bigCard, UUID gameId) {
|
||||||
this.loadCards(showCards, sortSetting, bigCard, gameId, true);
|
this.loadCards(showCards, sortSetting, bigCard, gameId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadCards(CardsView showCards, SortSetting sortSetting, BigCard bigCard, UUID gameId, boolean merge) {
|
public void loadCards(CardsView showCards, SortSetting sortSetting, BigCard bigCard, UUID gameId, boolean merge) {
|
||||||
boolean drawImage = showCards.size() <= MAX_IMAGES;
|
boolean drawImage = showCards.size() <= MAX_IMAGES;
|
||||||
this.bigCard = bigCard;
|
this.bigCard = bigCard;
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
if (merge) {
|
if (merge) {
|
||||||
for (CardView card : showCards.values()) {
|
for (CardView card : showCards.values()) {
|
||||||
if (!cards.containsKey(card.getId())) {
|
if (!cards.containsKey(card.getId())) {
|
||||||
addCard(card, bigCard, gameId, drawImage);
|
addCard(card, bigCard, gameId, drawImage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) {
|
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext(); ) {
|
||||||
Entry<UUID, MageCard> entry = i.next();
|
Entry<UUID, MageCard> entry = i.next();
|
||||||
if (!showCards.containsKey(entry.getKey())) {
|
if (!showCards.containsKey(entry.getKey())) {
|
||||||
removeCardImg(entry.getKey());
|
removeCardImg(entry.getKey());
|
||||||
i.remove();
|
i.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.clearCards();
|
this.clearCards();
|
||||||
for (CardView card : showCards.values()) {
|
for (CardView card : showCards.values()) {
|
||||||
addCard(card, bigCard, gameId, drawImage);
|
addCard(card, bigCard, gameId, drawImage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drawCards(sortSetting);
|
drawCards(sortSetting);
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, boolean drawImage) {
|
private void addCard(CardView card, BigCard bigCard, UUID gameId, boolean drawImage) {
|
||||||
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, drawImage, true);
|
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, drawImage, true, PreferencesDialog.getRenderMode());
|
||||||
cards.put(card.getId(), cardImg);
|
cards.put(card.getId(), cardImg);
|
||||||
cardImg.addMouseListener(this);
|
cardImg.addMouseListener(this);
|
||||||
add(cardImg);
|
add(cardImg);
|
||||||
cardImg.update(card);
|
cardImg.update(card);
|
||||||
cards.put(card.getId(), cardImg);
|
cards.put(card.getId(), cardImg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawCards(SortSetting sortSetting) {
|
public void drawCards(SortSetting sortSetting) {
|
||||||
int maxWidth = this.getParent().getWidth();
|
int maxWidth = this.getParent().getWidth();
|
||||||
int cardVerticalOffset = GUISizeHelper.editorCardOffsetSize;
|
int cardVerticalOffset = GUISizeHelper.editorCardOffsetSize;
|
||||||
int numColumns = maxWidth / cardDimension.width;
|
int numColumns = maxWidth / cardDimension.width;
|
||||||
int curColumn = 0;
|
int curColumn = 0;
|
||||||
int curRow = 0;
|
int curRow = 0;
|
||||||
if (!cards.isEmpty()) {
|
if (!cards.isEmpty()) {
|
||||||
Rectangle rectangle = new Rectangle(cardDimension.width, cardDimension.height);
|
Rectangle rectangle = new Rectangle(cardDimension.width, cardDimension.height);
|
||||||
List<MageCard> sortedCards = new ArrayList<>(cards.values());
|
List<MageCard> sortedCards = new ArrayList<>(cards.values());
|
||||||
switch (sortSetting.getSortBy()) {
|
switch (sortSetting.getSortBy()) {
|
||||||
case NAME:
|
case NAME:
|
||||||
sortedCards.sort(new CardNameComparator());
|
sortedCards.sort(new CardNameComparator());
|
||||||
break;
|
break;
|
||||||
case CARD_TYPE:
|
case CARD_TYPE:
|
||||||
sortedCards.sort(new CardTypeComparator());
|
sortedCards.sort(new CardTypeComparator());
|
||||||
break;
|
break;
|
||||||
case RARITY:
|
case RARITY:
|
||||||
sortedCards.sort(new CardRarityComparator());
|
sortedCards.sort(new CardRarityComparator());
|
||||||
break;
|
break;
|
||||||
case COLOR:
|
case COLOR:
|
||||||
sortedCards.sort(new CardColorComparator());
|
sortedCards.sort(new CardColorComparator());
|
||||||
break;
|
break;
|
||||||
case COLOR_IDENTITY:
|
case COLOR_IDENTITY:
|
||||||
sortedCards.sort(new CardColorDetailedIdentity());
|
sortedCards.sort(new CardColorDetailedIdentity());
|
||||||
break;
|
break;
|
||||||
case CASTING_COST:
|
case CASTING_COST:
|
||||||
sortedCards.sort(new CardCostComparator());
|
sortedCards.sort(new CardCostComparator());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
MageCard lastCard = null;
|
MageCard lastCard = null;
|
||||||
for (MageCard cardImg : sortedCards) {
|
for (MageCard cardImg : sortedCards) {
|
||||||
if (sortSetting.isPilesToggle()) {
|
if (sortSetting.isPilesToggle()) {
|
||||||
if (lastCard == null) {
|
if (lastCard == null) {
|
||||||
lastCard = cardImg;
|
lastCard = cardImg;
|
||||||
}
|
}
|
||||||
switch (sortSetting.getSortBy()) {
|
switch (sortSetting.getSortBy()) {
|
||||||
case NAME:
|
case NAME:
|
||||||
if (!cardImg.getOriginal().getName().equals(lastCard.getOriginal().getName())) {
|
if (!cardImg.getOriginal().getName().equals(lastCard.getOriginal().getName())) {
|
||||||
curColumn++;
|
curColumn++;
|
||||||
curRow = 0;
|
curRow = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CARD_TYPE:
|
case CARD_TYPE:
|
||||||
if (!cardImg.getOriginal().getCardTypes().equals(lastCard.getOriginal().getCardTypes())) {
|
if (!cardImg.getOriginal().getCardTypes().equals(lastCard.getOriginal().getCardTypes())) {
|
||||||
curColumn++;
|
curColumn++;
|
||||||
curRow = 0;
|
curRow = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RARITY:
|
case RARITY:
|
||||||
if (cardImg.getOriginal().getRarity() != lastCard.getOriginal().getRarity()) {
|
if (cardImg.getOriginal().getRarity() != lastCard.getOriginal().getRarity()) {
|
||||||
curColumn++;
|
curColumn++;
|
||||||
curRow = 0;
|
curRow = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COLOR:
|
case COLOR:
|
||||||
if (cardImg.getOriginal().getColor().compareTo(lastCard.getOriginal().getColor()) != 0) {
|
if (cardImg.getOriginal().getColor().compareTo(lastCard.getOriginal().getColor()) != 0) {
|
||||||
curColumn++;
|
curColumn++;
|
||||||
curRow = 0;
|
curRow = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COLOR_IDENTITY:
|
case COLOR_IDENTITY:
|
||||||
if (CardColorUtil.getColorIdentitySortValue(cardImg.getOriginal().getManaCost(), cardImg.getOriginal().getColor(), cardImg.getOriginal().getRules())
|
if (CardColorUtil.getColorIdentitySortValue(cardImg.getOriginal().getManaCost(), cardImg.getOriginal().getColor(), cardImg.getOriginal().getRules())
|
||||||
!= CardColorUtil.getColorIdentitySortValue(lastCard.getOriginal().getManaCost(), lastCard.getOriginal().getColor(), lastCard.getOriginal().getRules())) {
|
!= CardColorUtil.getColorIdentitySortValue(lastCard.getOriginal().getManaCost(), lastCard.getOriginal().getColor(), lastCard.getOriginal().getRules())) {
|
||||||
curColumn++;
|
curColumn++;
|
||||||
curRow = 0;
|
curRow = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CASTING_COST:
|
case CASTING_COST:
|
||||||
if (cardImg.getOriginal().getConvertedManaCost() != lastCard.getOriginal().getConvertedManaCost()) {
|
if (cardImg.getOriginal().getConvertedManaCost() != lastCard.getOriginal().getConvertedManaCost()) {
|
||||||
curColumn++;
|
curColumn++;
|
||||||
curRow = 0;
|
curRow = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rectangle.setLocation(curColumn * cardDimension.width, curRow * cardVerticalOffset);
|
rectangle.setLocation(curColumn * cardDimension.width, curRow * cardVerticalOffset);
|
||||||
cardImg.setBounds(rectangle);
|
cardImg.setBounds(rectangle);
|
||||||
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimension.width, cardDimension.height);
|
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimension.width, cardDimension.height);
|
||||||
moveToFront(cardImg);
|
moveToFront(cardImg);
|
||||||
curRow++;
|
curRow++;
|
||||||
lastCard = cardImg;
|
lastCard = cardImg;
|
||||||
} else {
|
} else {
|
||||||
rectangle.setLocation(curColumn * cardDimension.width, curRow * cardVerticalOffset);
|
rectangle.setLocation(curColumn * cardDimension.width, curRow * cardVerticalOffset);
|
||||||
cardImg.setBounds(rectangle);
|
cardImg.setBounds(rectangle);
|
||||||
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimension.width, cardDimension.height);
|
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimension.width, cardDimension.height);
|
||||||
moveToFront(cardImg);
|
moveToFront(cardImg);
|
||||||
curColumn++;
|
curColumn++;
|
||||||
if (curColumn == numColumns) {
|
if (curColumn == numColumns) {
|
||||||
curColumn = 0;
|
curColumn = 0;
|
||||||
curRow++;
|
curRow++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resizeArea();
|
resizeArea();
|
||||||
revalidate();
|
revalidate();
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearCards() {
|
private void clearCards() {
|
||||||
// remove possible mouse listeners, preventing gc
|
// remove possible mouse listeners, preventing gc
|
||||||
for (MageCard mageCard : cards.values()) {
|
for (MageCard mageCard : cards.values()) {
|
||||||
if (mageCard instanceof CardPanel) {
|
if (mageCard instanceof CardPanel) {
|
||||||
((CardPanel) mageCard).cleanUp();
|
((CardPanel) mageCard).cleanUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.cards.clear();
|
this.cards.clear();
|
||||||
removeAllCardImg();
|
removeAllCardImg();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeAllCardImg() {
|
private void removeAllCardImg() {
|
||||||
for (Component comp : getComponents()) {
|
for (Component comp : getComponents()) {
|
||||||
if (comp instanceof Card || comp instanceof MageCard) {
|
if (comp instanceof Card || comp instanceof MageCard) {
|
||||||
remove(comp);
|
remove(comp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeCardImg(UUID cardId) {
|
private void removeCardImg(UUID cardId) {
|
||||||
for (Component comp : getComponents()) {
|
for (Component comp : getComponents()) {
|
||||||
if (comp instanceof Card) {
|
if (comp instanceof Card) {
|
||||||
if (((Card) comp).getCardId().equals(cardId)) {
|
if (((Card) comp).getCardId().equals(cardId)) {
|
||||||
remove(comp);
|
remove(comp);
|
||||||
comp = null;
|
comp = null;
|
||||||
}
|
}
|
||||||
} else if (comp instanceof MageCard) {
|
} else if (comp instanceof MageCard) {
|
||||||
if (((MageCard) comp).getOriginal().getId().equals(cardId)) {
|
if (((MageCard) comp).getOriginal().getId().equals(cardId)) {
|
||||||
remove(comp);
|
remove(comp);
|
||||||
comp = null;
|
comp = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCard(UUID cardId) {
|
public void removeCard(UUID cardId) {
|
||||||
removeCardImg(cardId);
|
removeCardImg(cardId);
|
||||||
cards.remove(cardId);
|
cards.remove(cardId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCardEventListener(Listener<Event> listener) {
|
public void addCardEventListener(Listener<Event> listener) {
|
||||||
cardEventSource.addListener(listener);
|
cardEventSource.addListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearCardEventListeners() {
|
public void clearCardEventListeners() {
|
||||||
cardEventSource.clearListeners();
|
cardEventSource.clearListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called from within the constructor to initialize the form.
|
* This method is called from within the constructor to initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is always
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
* regenerated by the Form Editor.
|
* regenerated by the Form Editor.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
this.setLayout(layout);
|
this.setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGap(0, 294, Short.MAX_VALUE)
|
.addGap(0, 294, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGap(0, 197, Short.MAX_VALUE)
|
.addGap(0, 197, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
if ((e.getClickCount() & 1) == 0 && (e.getClickCount() > 0) && !e.isConsumed()) { // double clicks and repeated double clicks
|
if ((e.getClickCount() & 1) == 0 && (e.getClickCount() > 0) && !e.isConsumed()) { // double clicks and repeated double clicks
|
||||||
e.consume();
|
e.consume();
|
||||||
Object obj = e.getSource();
|
Object obj = e.getSource();
|
||||||
if (obj instanceof Card) {
|
if (obj instanceof Card) {
|
||||||
if (e.isAltDown()) {
|
if (e.isAltDown()) {
|
||||||
cardEventSource.fireEvent(((Card) obj).getOriginal(), ClientEventType.ALT_DOUBLE_CLICK);
|
cardEventSource.fireEvent(((Card) obj).getOriginal(), ClientEventType.ALT_DOUBLE_CLICK);
|
||||||
} else {
|
} else {
|
||||||
cardEventSource.fireEvent(((Card) obj).getOriginal(), ClientEventType.DOUBLE_CLICK);
|
cardEventSource.fireEvent(((Card) obj).getOriginal(), ClientEventType.DOUBLE_CLICK);
|
||||||
}
|
}
|
||||||
} else if (obj instanceof MageCard) {
|
} else if (obj instanceof MageCard) {
|
||||||
if (e.isAltDown()) {
|
if (e.isAltDown()) {
|
||||||
cardEventSource.fireEvent(((MageCard) obj).getOriginal(), ClientEventType.ALT_DOUBLE_CLICK);
|
cardEventSource.fireEvent(((MageCard) obj).getOriginal(), ClientEventType.ALT_DOUBLE_CLICK);
|
||||||
} else {
|
} else {
|
||||||
cardEventSource.fireEvent(((MageCard) obj).getOriginal(), ClientEventType.DOUBLE_CLICK);
|
cardEventSource.fireEvent(((MageCard) obj).getOriginal(), ClientEventType.DOUBLE_CLICK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(MouseEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e) {
|
public void mouseExited(MouseEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resizeArea() {
|
private void resizeArea() {
|
||||||
Dimension area = new Dimension(0, 0);
|
Dimension area = new Dimension(0, 0);
|
||||||
Dimension size = getPreferredSize();
|
Dimension size = getPreferredSize();
|
||||||
|
|
||||||
for (Component comp : getComponents()) {
|
for (Component comp : getComponents()) {
|
||||||
Rectangle r = comp.getBounds();
|
Rectangle r = comp.getBounds();
|
||||||
if (r.x + r.width > area.width) {
|
if (r.x + r.width > area.width) {
|
||||||
area.width = r.x + r.width;
|
area.width = r.x + r.width;
|
||||||
}
|
}
|
||||||
if (r.y + r.height > area.height) {
|
if (r.y + r.height > area.height) {
|
||||||
area.height = r.y + r.height;
|
area.height = r.y + r.height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (size.height != area.height || size.width != area.width) {
|
if (size.height != area.height || size.width != area.width) {
|
||||||
setPreferredSize(area);
|
setPreferredSize(area);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
revalidate();
|
revalidate();
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int cardsSize() {
|
public int cardsSize() {
|
||||||
return cards.size();
|
return cards.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CardNameComparator implements Comparator<MageCard> {
|
class CardNameComparator implements Comparator<MageCard> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(MageCard o1, MageCard o2) {
|
public int compare(MageCard o1, MageCard o2) {
|
||||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CardRarityComparator implements Comparator<MageCard> {
|
class CardRarityComparator implements Comparator<MageCard> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(MageCard o1, MageCard o2) {
|
public int compare(MageCard o1, MageCard o2) {
|
||||||
int val = o1.getOriginal().getRarity().compareTo(o2.getOriginal().getRarity());
|
int val = o1.getOriginal().getRarity().compareTo(o2.getOriginal().getRarity());
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||||
} else {
|
} else {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CardCostComparator implements Comparator<MageCard> {
|
class CardCostComparator implements Comparator<MageCard> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(MageCard o1, MageCard o2) {
|
public int compare(MageCard o1, MageCard o2) {
|
||||||
int val = Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(o2.getOriginal().getConvertedManaCost());
|
int val = Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(o2.getOriginal().getConvertedManaCost());
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||||
} else {
|
} else {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CardColorComparator implements Comparator<MageCard> {
|
class CardColorComparator implements Comparator<MageCard> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(MageCard o1, MageCard o2) {
|
public int compare(MageCard o1, MageCard o2) {
|
||||||
int val = o1.getOriginal().getColor().compareTo(o2.getOriginal().getColor());
|
int val = o1.getOriginal().getColor().compareTo(o2.getOriginal().getColor());
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||||
} else {
|
} else {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CardColorDetailedIdentity implements Comparator<MageCard> {
|
class CardColorDetailedIdentity implements Comparator<MageCard> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(MageCard o1, MageCard o2) {
|
public int compare(MageCard o1, MageCard o2) {
|
||||||
int val = CardColorUtil.getColorIdentitySortValue(o1.getOriginal().getManaCost(), o1.getOriginal().getColor(), o1.getOriginal().getRules())
|
int val = CardColorUtil.getColorIdentitySortValue(o1.getOriginal().getManaCost(), o1.getOriginal().getColor(), o1.getOriginal().getRules())
|
||||||
- CardColorUtil.getColorIdentitySortValue(o2.getOriginal().getManaCost(), o2.getOriginal().getColor(), o2.getOriginal().getRules());
|
- CardColorUtil.getColorIdentitySortValue(o2.getOriginal().getManaCost(), o2.getOriginal().getColor(), o2.getOriginal().getRules());
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||||
} else {
|
} else {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CardTypeComparator implements Comparator<MageCard> {
|
class CardTypeComparator implements Comparator<MageCard> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(MageCard o1, MageCard o2) {
|
public int compare(MageCard o1, MageCard o2) {
|
||||||
int val = o1.getOriginal().getCardTypes().toString().compareTo(o2.getOriginal().getCardTypes().toString());
|
int val = o1.getOriginal().getCardTypes().toString().compareTo(o2.getOriginal().getCardTypes().toString());
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||||
} else {
|
} else {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
package mage.client.cards;
|
package mage.client.cards;
|
||||||
|
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.CardsViewUtil;
|
import mage.client.util.CardsViewUtil;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
|
|
@ -227,7 +228,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
|
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
|
||||||
MageCard mageCard = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
|
MageCard mageCard = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true, PreferencesDialog.getRenderMode());
|
||||||
if (zone != null) {
|
if (zone != null) {
|
||||||
mageCard.setZone(zone);
|
mageCard.setZone(zone);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -10,6 +10,7 @@ package mage.client.cards;
|
||||||
|
|
||||||
import mage.cards.CardDimensions;
|
import mage.cards.CardDimensions;
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.CardViewRarityComparator;
|
import mage.client.util.CardViewRarityComparator;
|
||||||
import mage.client.util.ClientEventType;
|
import mage.client.util.ClientEventType;
|
||||||
|
|
@ -28,7 +29,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
||||||
|
|
@ -40,17 +40,19 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
||||||
protected MageCard markedCard;
|
protected MageCard markedCard;
|
||||||
protected boolean emptyGrid;
|
protected boolean emptyGrid;
|
||||||
|
|
||||||
/** Creates new form DraftGrid */
|
/**
|
||||||
|
* Creates new form DraftGrid
|
||||||
|
*/
|
||||||
public DraftGrid() {
|
public DraftGrid() {
|
||||||
initComponents();
|
initComponents();
|
||||||
markedCard = null;
|
markedCard = null;
|
||||||
emptyGrid= true;
|
emptyGrid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
markedCard = null;
|
markedCard = null;
|
||||||
this.clearCardEventListeners();
|
this.clearCardEventListeners();
|
||||||
for (Component comp: getComponents()) {
|
for (Component comp : getComponents()) {
|
||||||
if (comp instanceof Card || comp instanceof MageCard) {
|
if (comp instanceof Card || comp instanceof MageCard) {
|
||||||
this.remove(comp);
|
this.remove(comp);
|
||||||
}
|
}
|
||||||
|
|
@ -79,10 +81,10 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
||||||
|
|
||||||
CardDimensions cardDimension = null;
|
CardDimensions cardDimension = null;
|
||||||
int maxCards;
|
int maxCards;
|
||||||
double scale ;
|
double scale;
|
||||||
|
|
||||||
for (int i = 1; i < maxRows; i++) {
|
for (int i = 1; i < maxRows; i++) {
|
||||||
scale = (double) (this.getHeight()/i) / Constants.FRAME_MAX_HEIGHT;
|
scale = (double) (this.getHeight() / i) / Constants.FRAME_MAX_HEIGHT;
|
||||||
cardDimension = new CardDimensions(scale);
|
cardDimension = new CardDimensions(scale);
|
||||||
maxCards = this.getWidth() / (cardDimension.getFrameWidth() + offsetX);
|
maxCards = this.getWidth() / (cardDimension.getFrameWidth() + offsetX);
|
||||||
if ((maxCards * i) >= booster.size()) {
|
if ((maxCards * i) >= booster.size()) {
|
||||||
|
|
@ -100,8 +102,8 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
||||||
|
|
||||||
List<CardView> sortedCards = new ArrayList<>(booster.values());
|
List<CardView> sortedCards = new ArrayList<>(booster.values());
|
||||||
sortedCards.sort(new CardViewRarityComparator());
|
sortedCards.sort(new CardViewRarityComparator());
|
||||||
for (CardView card: sortedCards) {
|
for (CardView card : sortedCards) {
|
||||||
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, dimension, null, true, true);
|
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, dimension, null, true, true, PreferencesDialog.getRenderMode());
|
||||||
cardImg.addMouseListener(this);
|
cardImg.addMouseListener(this);
|
||||||
add(cardImg);
|
add(cardImg);
|
||||||
cardImg.update(card);
|
cardImg.update(card);
|
||||||
|
|
@ -133,7 +135,8 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
||||||
Plugins.instance.getActionCallback().mouseExited(null, null);
|
Plugins.instance.getActionCallback().mouseExited(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/**
|
||||||
|
* This method is called from within the constructor to
|
||||||
* initialize the form.
|
* initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* WARNING: Do NOT modify this code. The content of this method is
|
||||||
* always regenerated by the Form Editor.
|
* always regenerated by the Form Editor.
|
||||||
|
|
@ -145,12 +148,12 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
this.setLayout(layout);
|
this.setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGap(0, 400, Short.MAX_VALUE)
|
.addGap(0, 400, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGap(0, 300, Short.MAX_VALUE)
|
.addGap(0, 300, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
|
@ -160,7 +163,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
||||||
if (e.getButton() == MouseEvent.BUTTON1) {
|
if (e.getButton() == MouseEvent.BUTTON1) {
|
||||||
Object obj = e.getSource();
|
Object obj = e.getSource();
|
||||||
if (obj instanceof MageCard) {
|
if (obj instanceof MageCard) {
|
||||||
this.cardEventSource.fireEvent(((MageCard)obj).getOriginal(), ClientEventType.PICK_A_CARD);
|
this.cardEventSource.fireEvent(((MageCard) obj).getOriginal(), ClientEventType.PICK_A_CARD);
|
||||||
this.hidePopup();
|
this.hidePopup();
|
||||||
AudioManager.playOnDraftSelect();
|
AudioManager.playOnDraftSelect();
|
||||||
}
|
}
|
||||||
|
|
@ -177,8 +180,8 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
||||||
if (this.markedCard != null) {
|
if (this.markedCard != null) {
|
||||||
markedCard.setSelected(false);
|
markedCard.setSelected(false);
|
||||||
}
|
}
|
||||||
this.cardEventSource.fireEvent(((MageCard)obj).getOriginal(), ClientEventType.MARK_A_CARD);
|
this.cardEventSource.fireEvent(((MageCard) obj).getOriginal(), ClientEventType.MARK_A_CARD);
|
||||||
markedCard = ((MageCard)obj);
|
markedCard = ((MageCard) obj);
|
||||||
markedCard.setSelected(true);
|
markedCard.setSelected(true);
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,5 @@
|
||||||
package mage.client.cards;
|
package mage.client.cards;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.KeyAdapter;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import javax.swing.*;
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
import mage.cards.decks.DeckCardInfo;
|
import mage.cards.decks.DeckCardInfo;
|
||||||
|
|
@ -31,6 +20,18 @@ import mage.view.CardsView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.mage.card.arcane.CardRenderer;
|
import org.mage.card.arcane.CardRenderer;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.KeyAdapter;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by StravantUser on 2016-09-20.
|
* Created by StravantUser on 2016-09-20.
|
||||||
*/
|
*/
|
||||||
|
|
@ -456,6 +457,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
--count;
|
--count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int count = 0;
|
private int count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -511,14 +513,14 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
};
|
};
|
||||||
|
|
||||||
private final CardTypeCounter[] allCounters = {
|
private final CardTypeCounter[] allCounters = {
|
||||||
creatureCounter,
|
creatureCounter,
|
||||||
landCounter,
|
landCounter,
|
||||||
artifactCounter,
|
artifactCounter,
|
||||||
enchantmentCounter,
|
enchantmentCounter,
|
||||||
instantCounter,
|
instantCounter,
|
||||||
planeswalkerCounter,
|
planeswalkerCounter,
|
||||||
sorceryCounter,
|
sorceryCounter,
|
||||||
tribalCounter
|
tribalCounter
|
||||||
};
|
};
|
||||||
|
|
||||||
// Listener
|
// Listener
|
||||||
|
|
@ -659,7 +661,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return '(' + sort.toString() + ',' + Boolean.toString(separateCreatures) + ',' + Integer.toString(cardSize) + ')';
|
return '(' + sort.toString() + ',' + separateCreatures + ',' + cardSize + ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1767,7 +1769,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
updateCounts();
|
updateCounts();
|
||||||
|
|
||||||
// Create the card view
|
// Create the card view
|
||||||
final MageCard cardPanel = Plugins.instance.getMageCard(card, lastBigCard, new Dimension(getCardWidth(), getCardHeight()), null, true, true);
|
final MageCard cardPanel = Plugins.instance.getMageCard(card, lastBigCard, new Dimension(getCardWidth(), getCardHeight()), null, true, true, PreferencesDialog.getRenderMode());
|
||||||
cardPanel.update(card);
|
cardPanel.update(card);
|
||||||
cardPanel.setCardCaptionTopOffset(0);
|
cardPanel.setCardCaptionTopOffset(0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import mage.client.components.ext.dlg.DialogContainer;
|
||||||
import mage.client.components.ext.dlg.DialogManager;
|
import mage.client.components.ext.dlg.DialogManager;
|
||||||
import mage.client.components.ext.dlg.DlgParams;
|
import mage.client.components.ext.dlg.DlgParams;
|
||||||
import mage.client.components.ext.dlg.IDialogPanel;
|
import mage.client.components.ext.dlg.IDialogPanel;
|
||||||
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.Command;
|
import mage.client.util.Command;
|
||||||
import mage.client.util.SettingsManager;
|
import mage.client.util.SettingsManager;
|
||||||
|
|
@ -162,7 +163,7 @@ public class ChoiceDialog extends IDialogPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
CardView card = cardList.get(i);
|
CardView card = cardList.get(i);
|
||||||
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
|
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true, PreferencesDialog.getRenderMode());
|
||||||
|
|
||||||
cardImg.setLocation(dx, dy + j * (height + 30));
|
cardImg.setLocation(dx, dy + j * (height + 30));
|
||||||
add(cardImg);
|
add(cardImg);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import mage.client.components.ext.dlg.DialogContainer;
|
||||||
import mage.client.components.ext.dlg.DialogManager;
|
import mage.client.components.ext.dlg.DialogManager;
|
||||||
import mage.client.components.ext.dlg.DlgParams;
|
import mage.client.components.ext.dlg.DlgParams;
|
||||||
import mage.client.components.ext.dlg.IDialogPanel;
|
import mage.client.components.ext.dlg.IDialogPanel;
|
||||||
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import mage.client.game.FeedbackPanel;
|
import mage.client.game.FeedbackPanel;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.Command;
|
import mage.client.util.Command;
|
||||||
|
|
@ -40,7 +41,7 @@ public class StackDialog extends IDialogPanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
Graphics2D g2D = (Graphics2D)g;
|
Graphics2D g2D = (Graphics2D) g;
|
||||||
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
|
||||||
|
|
@ -111,7 +112,7 @@ public class StackDialog extends IDialogPanel {
|
||||||
for (CardView card : cards.values()) {
|
for (CardView card : cards.values()) {
|
||||||
|
|
||||||
if (card instanceof StackAbilityView) {
|
if (card instanceof StackAbilityView) {
|
||||||
CardView tmp = ((StackAbilityView)card).getSourceCard();
|
CardView tmp = ((StackAbilityView) card).getSourceCard();
|
||||||
tmp.overrideRules(card.getRules());
|
tmp.overrideRules(card.getRules());
|
||||||
tmp.setIsAbility(true);
|
tmp.setIsAbility(true);
|
||||||
tmp.overrideTargets(card.getTargets());
|
tmp.overrideTargets(card.getTargets());
|
||||||
|
|
@ -119,7 +120,7 @@ public class StackDialog extends IDialogPanel {
|
||||||
card = tmp;
|
card = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
|
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true, PreferencesDialog.getRenderMode());
|
||||||
//cardImg.setBorder(BorderFactory.createLineBorder(Color.red));
|
//cardImg.setBorder(BorderFactory.createLineBorder(Color.red));
|
||||||
cardImg.setLocation(dx, dy);
|
cardImg.setLocation(dx, dy);
|
||||||
|
|
||||||
|
|
@ -143,10 +144,11 @@ public class StackDialog extends IDialogPanel {
|
||||||
jButtonAccept.setObserver(new Command() {
|
jButtonAccept.setObserver(new Command() {
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
DialogManager.getManager(gameId).fadeOut((DialogContainer)getParent());
|
DialogManager.getManager(gameId).fadeOut((DialogContainer) getParent());
|
||||||
//GameManager.getInputControl().getInput().selectButtonOK();
|
//GameManager.getInputControl().getInput().selectButtonOK();
|
||||||
StackDialog.this.feedbackPanel.doClick();
|
StackDialog.this.feedbackPanel.doClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -166,11 +168,12 @@ public class StackDialog extends IDialogPanel {
|
||||||
jButtonResponse.setObserver(new Command() {
|
jButtonResponse.setObserver(new Command() {
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
DialogManager.getManager(gameId).fadeOut((DialogContainer)getParent());
|
DialogManager.getManager(gameId).fadeOut((DialogContainer) getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return jButtonResponse;
|
return jButtonResponse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -8,6 +8,7 @@ import mage.cards.repository.ExpansionRepository;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
import mage.client.components.HoverButton;
|
import mage.client.components.HoverButton;
|
||||||
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.client.util.ImageHelper;
|
import mage.client.util.ImageHelper;
|
||||||
|
|
@ -406,7 +407,7 @@ public class MageBook extends JComponent {
|
||||||
if (cardDimension == null) {
|
if (cardDimension == null) {
|
||||||
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
|
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
|
||||||
}
|
}
|
||||||
final MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true);
|
final MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true, PreferencesDialog.getRenderMode());
|
||||||
cardImg.setBounds(rectangle);
|
cardImg.setBounds(rectangle);
|
||||||
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
|
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
|
||||||
cardImg.update(card);
|
cardImg.update(card);
|
||||||
|
|
@ -447,7 +448,7 @@ public class MageBook extends JComponent {
|
||||||
newToken.removeSummoningSickness();
|
newToken.removeSummoningSickness();
|
||||||
PermanentView theToken = new PermanentView(newToken, null, null, null);
|
PermanentView theToken = new PermanentView(newToken, null, null, null);
|
||||||
theToken.setInViewerOnly(true);
|
theToken.setInViewerOnly(true);
|
||||||
final MageCard cardImg = Plugins.instance.getMagePermanent(theToken, bigCard, cardDimension, gameId, true);
|
final MageCard cardImg = Plugins.instance.getMagePermanent(theToken, bigCard, cardDimension, gameId, true, PreferencesDialog.getRenderMode());
|
||||||
cardImg.setBounds(rectangle);
|
cardImg.setBounds(rectangle);
|
||||||
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
|
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
|
||||||
cardImg.update(theToken);
|
cardImg.update(theToken);
|
||||||
|
|
|
||||||
|
|
@ -3714,6 +3714,14 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getRenderMode() {
|
||||||
|
if (getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_FALLBACK, "false").equals("false")) {
|
||||||
|
return 0; // mtgo
|
||||||
|
} else {
|
||||||
|
return 1; // image
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static int getDefaultControlMofier(String key) {
|
private static int getDefaultControlMofier(String key) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||||
<Properties>
|
|
||||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
|
||||||
</Properties>
|
|
||||||
<SyntheticProperties>
|
<SyntheticProperties>
|
||||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
|
||||||
</SyntheticProperties>
|
</SyntheticProperties>
|
||||||
<AuxValues>
|
<AuxValues>
|
||||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||||
|
|
@ -30,9 +26,17 @@
|
||||||
<EmptySpace min="0" pref="578" max="32767" attributes="0"/>
|
<EmptySpace min="0" pref="578" max="32767" attributes="0"/>
|
||||||
<Component id="buttonCancel" min="-2" pref="100" max="-2" attributes="0"/>
|
<Component id="buttonCancel" min="-2" pref="100" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<Component id="cardArea1" alignment="0" max="32767" attributes="0"/>
|
<Component id="cardsPanel" alignment="0" max="32767" attributes="0"/>
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
<Component id="buttonReloadCards" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="labelRenderMode" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="comboRenderMode" min="-2" pref="131" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="labelSize" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="sliderSize" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
@ -44,9 +48,17 @@
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="1" attributes="0">
|
<Group type="102" alignment="1" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
<Group type="103" groupAlignment="1" attributes="0">
|
||||||
<EmptySpace pref="88" max="32767" attributes="0"/>
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
<Component id="cardArea1" min="-2" pref="327" max="-2" attributes="0"/>
|
<Component id="buttonReloadCards" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="labelRenderMode" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="comboRenderMode" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="labelSize" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<Component id="sliderSize" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="cardsPanel" pref="421" max="32767" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="buttonCancel" min="-2" pref="30" max="-2" attributes="0"/>
|
<Component id="buttonCancel" min="-2" pref="30" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
|
@ -63,15 +75,49 @@
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="mage.client.cards.CardArea" name="cardArea1">
|
<Component class="mage.client.cards.CardArea" name="cardsPanel">
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JButton" name="jButton1">
|
<Component class="javax.swing.JButton" name="buttonReloadCards">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="text" type="java.lang.String" value="jButton1"/>
|
<Property name="text" type="java.lang.String" value="Reload cards"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonReloadCardsActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="labelRenderMode">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Render mode:"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JComboBox" name="comboRenderMode">
|
||||||
|
<Properties>
|
||||||
|
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||||
|
<StringArray count="2">
|
||||||
|
<StringItem index="0" value="MTGO"/>
|
||||||
|
<StringItem index="1" value="Image"/>
|
||||||
|
</StringArray>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="comboRenderModeItemStateChanged"/>
|
||||||
|
</Events>
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||||
|
</AuxValues>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JSlider" name="sliderSize">
|
||||||
|
<Properties>
|
||||||
|
<Property name="value" type="int" value="25"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="sliderSizeStateChanged"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="labelSize">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Card size:"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import mage.cards.repository.ExpansionInfo;
|
||||||
import mage.cards.repository.ExpansionRepository;
|
import mage.cards.repository.ExpansionRepository;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
|
import mage.client.util.GUISizeHelper;
|
||||||
import mage.constants.MultiplayerAttackOption;
|
import mage.constants.MultiplayerAttackOption;
|
||||||
import mage.constants.RangeOfInfluence;
|
import mage.constants.RangeOfInfluence;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
@ -26,6 +27,7 @@ import mage.view.PermanentView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
@ -35,6 +37,7 @@ import java.util.UUID;
|
||||||
public class TestCardRenderDialog extends MageDialog {
|
public class TestCardRenderDialog extends MageDialog {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(TestCardRenderDialog.class);
|
private static final Logger logger = Logger.getLogger(TestCardRenderDialog.class);
|
||||||
|
float cardSizeMod = 1.0f;
|
||||||
|
|
||||||
public TestCardRenderDialog() {
|
public TestCardRenderDialog() {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
@ -43,6 +46,7 @@ public class TestCardRenderDialog extends MageDialog {
|
||||||
public void showDialog() {
|
public void showDialog() {
|
||||||
this.setModal(false);
|
this.setModal(false);
|
||||||
getRootPane().setDefaultButton(buttonCancel);
|
getRootPane().setDefaultButton(buttonCancel);
|
||||||
|
reloadCards();
|
||||||
|
|
||||||
// windows settings
|
// windows settings
|
||||||
MageFrame.getDesktop().remove(this);
|
MageFrame.getDesktop().remove(this);
|
||||||
|
|
@ -74,77 +78,17 @@ public class TestCardRenderDialog extends MageDialog {
|
||||||
if (damage > 0) {
|
if (damage > 0) {
|
||||||
perm.damage(damage, null, game);
|
perm.damage(damage, null, game);
|
||||||
}
|
}
|
||||||
|
perm.removeSummoningSickness();
|
||||||
PermanentView cardView = new PermanentView(perm, card, controllerId, game);
|
PermanentView cardView = new PermanentView(perm, card, controllerId, game);
|
||||||
cardView.setInViewerOnly(true);
|
cardView.setInViewerOnly(true);
|
||||||
|
|
||||||
return cardView;
|
return cardView;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void reloadCards() {
|
||||||
* This method is called from within the constructor to initialize the form.
|
cardsPanel.cleanUp();
|
||||||
* WARNING: Do NOT modify this code. The content of this method is always
|
cardsPanel.setCustomRenderMode(comboRenderMode.getSelectedIndex());
|
||||||
* regenerated by the Form Editor.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
||||||
private void initComponents() {
|
|
||||||
|
|
||||||
buttonCancel = new javax.swing.JButton();
|
|
||||||
cardArea1 = new mage.client.cards.CardArea();
|
|
||||||
jButton1 = new javax.swing.JButton();
|
|
||||||
|
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
|
||||||
|
|
||||||
buttonCancel.setText("Close");
|
|
||||||
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
|
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
||||||
buttonCancelActionPerformed(evt);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
jButton1.setText("jButton1");
|
|
||||||
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
||||||
jButton1ActionPerformed(evt);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
|
||||||
getContentPane().setLayout(layout);
|
|
||||||
layout.setHorizontalGroup(
|
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addContainerGap()
|
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
|
||||||
.addGap(0, 578, Short.MAX_VALUE)
|
|
||||||
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
||||||
.addComponent(cardArea1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addComponent(jButton1)
|
|
||||||
.addGap(0, 0, Short.MAX_VALUE)))
|
|
||||||
.addContainerGap())
|
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
|
||||||
.addContainerGap()
|
|
||||||
.addComponent(jButton1)
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 88, Short.MAX_VALUE)
|
|
||||||
.addComponent(cardArea1, javax.swing.GroupLayout.PREFERRED_SIZE, 327, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
||||||
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addContainerGap())
|
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
|
||||||
|
|
||||||
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
|
|
||||||
onCancel();
|
|
||||||
}//GEN-LAST:event_buttonCancelActionPerformed
|
|
||||||
|
|
||||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
|
||||||
Game game = new TestGame(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, new VancouverMulligan(0), 20);
|
Game game = new TestGame(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, new VancouverMulligan(0), 20);
|
||||||
Player player = new StubPlayer("player1", RangeOfInfluence.ALL);
|
Player player = new StubPlayer("player1", RangeOfInfluence.ALL);
|
||||||
Deck deck = new Deck();
|
Deck deck = new Deck();
|
||||||
|
|
@ -160,13 +104,147 @@ public class TestCardRenderDialog extends MageDialog {
|
||||||
card = createCard(game, player.getId(), "RNA", "14", 1); // Knight of Sorrows
|
card = createCard(game, player.getId(), "RNA", "14", 1); // Knight of Sorrows
|
||||||
view.put(card.getId(), card);
|
view.put(card.getId(), card);
|
||||||
|
|
||||||
cardArea1.loadCards(view, big, null);
|
cardsPanel.setCustomCardSize(new Dimension(getCardWidth(), getCardHeight()));
|
||||||
}//GEN-LAST:event_jButton1ActionPerformed
|
cardsPanel.changeGUISize();
|
||||||
|
|
||||||
|
cardsPanel.loadCards(view, big, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getCardWidth() {
|
||||||
|
if (GUISizeHelper.editorCardDimension == null) {
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
return (int) (GUISizeHelper.editorCardDimension.width * cardSizeMod);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getCardHeight() {
|
||||||
|
return (int) (1.4 * getCardWidth());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called from within the constructor to initialize the form.
|
||||||
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
|
* regenerated by the Form Editor.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
buttonCancel = new javax.swing.JButton();
|
||||||
|
cardsPanel = new mage.client.cards.CardArea();
|
||||||
|
buttonReloadCards = new javax.swing.JButton();
|
||||||
|
labelRenderMode = new javax.swing.JLabel();
|
||||||
|
comboRenderMode = new javax.swing.JComboBox<>();
|
||||||
|
sliderSize = new javax.swing.JSlider();
|
||||||
|
labelSize = new javax.swing.JLabel();
|
||||||
|
|
||||||
|
buttonCancel.setText("Close");
|
||||||
|
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
buttonCancelActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonReloadCards.setText("Reload cards");
|
||||||
|
buttonReloadCards.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
buttonReloadCardsActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
labelRenderMode.setText("Render mode:");
|
||||||
|
|
||||||
|
comboRenderMode.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"MTGO", "Image"}));
|
||||||
|
comboRenderMode.addItemListener(new java.awt.event.ItemListener() {
|
||||||
|
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||||
|
comboRenderModeItemStateChanged(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
sliderSize.setValue(25);
|
||||||
|
sliderSize.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||||
|
public void stateChanged(javax.swing.event.ChangeEvent evt) {
|
||||||
|
sliderSizeStateChanged(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
labelSize.setText("Card size:");
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addGap(0, 578, Short.MAX_VALUE)
|
||||||
|
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addComponent(cardsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(buttonReloadCards)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(labelRenderMode)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(comboRenderMode, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(labelSize)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(sliderSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(0, 0, Short.MAX_VALUE)))
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(buttonReloadCards)
|
||||||
|
.addComponent(labelRenderMode)
|
||||||
|
.addComponent(comboRenderMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(labelSize))
|
||||||
|
.addComponent(sliderSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(cardsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
|
||||||
|
pack();
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
|
||||||
|
onCancel();
|
||||||
|
}//GEN-LAST:event_buttonCancelActionPerformed
|
||||||
|
|
||||||
|
private void buttonReloadCardsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReloadCardsActionPerformed
|
||||||
|
reloadCards();
|
||||||
|
}//GEN-LAST:event_buttonReloadCardsActionPerformed
|
||||||
|
|
||||||
|
private void comboRenderModeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboRenderModeItemStateChanged
|
||||||
|
reloadCards();
|
||||||
|
}//GEN-LAST:event_comboRenderModeItemStateChanged
|
||||||
|
|
||||||
|
private void sliderSizeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderSizeStateChanged
|
||||||
|
// from DragCardGrid
|
||||||
|
// Fraction in [-1, 1]
|
||||||
|
float sliderFrac = ((float) (sliderSize.getValue() - 50)) / 50;
|
||||||
|
// Convert to frac in [0.5, 2.0] exponentially
|
||||||
|
cardSizeMod = (float) Math.pow(2, sliderFrac);
|
||||||
|
reloadCards();
|
||||||
|
}//GEN-LAST:event_sliderSizeStateChanged
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JButton buttonCancel;
|
private javax.swing.JButton buttonCancel;
|
||||||
private mage.client.cards.CardArea cardArea1;
|
private javax.swing.JButton buttonReloadCards;
|
||||||
private javax.swing.JButton jButton1;
|
private mage.client.cards.CardArea cardsPanel;
|
||||||
|
private javax.swing.JComboBox<String> comboRenderMode;
|
||||||
|
private javax.swing.JLabel labelRenderMode;
|
||||||
|
private javax.swing.JLabel labelSize;
|
||||||
|
private javax.swing.JSlider sliderSize;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,254 +1,245 @@
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BattlefieldPanel.java
|
* BattlefieldPanel.java
|
||||||
*
|
*
|
||||||
* Created on 10-Jan-2010, 10:43:14 PM
|
* Created on 10-Jan-2010, 10:43:14 PM
|
||||||
*/
|
*/
|
||||||
package mage.client.game;
|
package mage.client.game;
|
||||||
|
|
||||||
import java.awt.Component;
|
import mage.cards.MagePermanent;
|
||||||
import java.awt.Dimension;
|
import mage.client.cards.BigCard;
|
||||||
import java.awt.event.ComponentAdapter;
|
import mage.client.cards.Permanent;
|
||||||
import java.awt.event.ComponentEvent;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import java.util.ArrayList;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import java.util.HashMap;
|
import mage.client.util.Config;
|
||||||
import java.util.HashSet;
|
import mage.client.util.GUISizeHelper;
|
||||||
import java.util.Iterator;
|
import mage.client.util.audio.AudioManager;
|
||||||
import java.util.LinkedHashMap;
|
import mage.client.util.layout.CardLayoutStrategy;
|
||||||
import java.util.List;
|
import mage.client.util.layout.impl.OldCardLayoutStrategy;
|
||||||
import java.util.Map;
|
import mage.view.CounterView;
|
||||||
import java.util.Map.Entry;
|
import mage.view.PermanentView;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JLayeredPane;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.border.Border;
|
|
||||||
import javax.swing.border.EmptyBorder;
|
|
||||||
import mage.cards.MagePermanent;
|
|
||||||
import mage.client.cards.BigCard;
|
|
||||||
import mage.client.cards.Permanent;
|
|
||||||
import mage.client.plugins.impl.Plugins;
|
|
||||||
import mage.client.util.Config;
|
|
||||||
import mage.client.util.GUISizeHelper;
|
|
||||||
import mage.client.util.audio.AudioManager;
|
|
||||||
import mage.client.util.layout.CardLayoutStrategy;
|
|
||||||
import mage.client.util.layout.impl.OldCardLayoutStrategy;
|
|
||||||
import mage.view.CounterView;
|
|
||||||
import mage.view.PermanentView;
|
|
||||||
|
|
||||||
/**
|
import javax.swing.*;
|
||||||
*
|
import javax.swing.border.Border;
|
||||||
* @author BetaSteward_at_googlemail.com
|
import javax.swing.border.EmptyBorder;
|
||||||
*/
|
import java.awt.*;
|
||||||
public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
import java.awt.event.ComponentAdapter;
|
||||||
|
import java.awt.event.ComponentEvent;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
private final Map<UUID, MagePermanent> permanents = new LinkedHashMap<>();
|
/**
|
||||||
private UUID gameId;
|
* @author BetaSteward_at_googlemail.com
|
||||||
private BigCard bigCard;
|
*/
|
||||||
private final Map<String, JComponent> uiComponentsList = new HashMap<>();
|
public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
||||||
|
|
||||||
protected Map<UUID, PermanentView> battlefield;
|
private final Map<UUID, MagePermanent> permanents = new LinkedHashMap<>();
|
||||||
private Dimension cardDimension;
|
private UUID gameId;
|
||||||
|
private BigCard bigCard;
|
||||||
|
private final Map<String, JComponent> uiComponentsList = new HashMap<>();
|
||||||
|
|
||||||
private JLayeredPane jPanel;
|
protected Map<UUID, PermanentView> battlefield;
|
||||||
private JScrollPane jScrollPane;
|
private Dimension cardDimension;
|
||||||
private int width;
|
|
||||||
|
|
||||||
private final CardLayoutStrategy layoutStrategy = new OldCardLayoutStrategy();
|
private JLayeredPane jPanel;
|
||||||
|
private JScrollPane jScrollPane;
|
||||||
|
private int width;
|
||||||
|
|
||||||
//private static int iCounter = 0;
|
private final CardLayoutStrategy layoutStrategy = new OldCardLayoutStrategy();
|
||||||
private boolean addedPermanent;
|
|
||||||
private boolean addedArtifact;
|
|
||||||
private boolean addedCreature;
|
|
||||||
|
|
||||||
private boolean removedCreature;
|
//private static int iCounter = 0;
|
||||||
// defines if the battlefield is within a top (means top row of player panels) or a bottom player panel
|
private boolean addedPermanent;
|
||||||
private boolean topPanelBattlefield;
|
private boolean addedArtifact;
|
||||||
|
private boolean addedCreature;
|
||||||
|
|
||||||
/**
|
private boolean removedCreature;
|
||||||
* Creates new form BattlefieldPanel
|
// defines if the battlefield is within a top (means top row of player panels) or a bottom player panel
|
||||||
*/
|
private boolean topPanelBattlefield;
|
||||||
public BattlefieldPanel() {
|
|
||||||
uiComponentsList.put("battlefieldPanel", this);
|
|
||||||
initComponents();
|
|
||||||
uiComponentsList.put("jPanel", jPanel);
|
|
||||||
setGUISize();
|
|
||||||
|
|
||||||
addComponentListener(new ComponentAdapter() {
|
/**
|
||||||
@Override
|
* Creates new form BattlefieldPanel
|
||||||
public void componentResized(ComponentEvent e) {
|
*/
|
||||||
int width = e.getComponent().getWidth();
|
public BattlefieldPanel() {
|
||||||
int height = e.getComponent().getHeight();
|
uiComponentsList.put("battlefieldPanel", this);
|
||||||
BattlefieldPanel.this.jScrollPane.setSize(width, height);
|
initComponents();
|
||||||
BattlefieldPanel.this.width = width;
|
uiComponentsList.put("jPanel", jPanel);
|
||||||
sortLayout();
|
setGUISize();
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init(UUID gameId, BigCard bigCard) {
|
addComponentListener(new ComponentAdapter() {
|
||||||
this.gameId = gameId;
|
@Override
|
||||||
this.bigCard = bigCard;
|
public void componentResized(ComponentEvent e) {
|
||||||
}
|
int width = e.getComponent().getWidth();
|
||||||
|
int height = e.getComponent().getHeight();
|
||||||
|
BattlefieldPanel.this.jScrollPane.setSize(width, height);
|
||||||
|
BattlefieldPanel.this.width = width;
|
||||||
|
sortLayout();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void cleanUp() {
|
public void init(UUID gameId, BigCard bigCard) {
|
||||||
for (Component c : this.jPanel.getComponents()) {
|
this.gameId = gameId;
|
||||||
if (c instanceof Permanent || c instanceof MagePermanent) {
|
this.bigCard = bigCard;
|
||||||
this.jPanel.remove(c);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
permanents.clear();
|
|
||||||
// Plugins.getInstance().sortPermanents(uiComponentsList, permanents.values());
|
|
||||||
this.bigCard = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changeGUISize() {
|
public void cleanUp() {
|
||||||
setGUISize();
|
for (Component c : this.jPanel.getComponents()) {
|
||||||
sortLayout();
|
if (c instanceof Permanent || c instanceof MagePermanent) {
|
||||||
}
|
this.jPanel.remove(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
permanents.clear();
|
||||||
|
// Plugins.getInstance().sortPermanents(uiComponentsList, permanents.values());
|
||||||
|
this.bigCard = null;
|
||||||
|
}
|
||||||
|
|
||||||
private void setGUISize() {
|
public void changeGUISize() {
|
||||||
jScrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0));
|
setGUISize();
|
||||||
jScrollPane.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GUISizeHelper.scrollBarSize));
|
sortLayout();
|
||||||
cardDimension = GUISizeHelper.battlefieldCardMaxDimension;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTopPanelBattlefield() {
|
private void setGUISize() {
|
||||||
return topPanelBattlefield;
|
jScrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0));
|
||||||
}
|
jScrollPane.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GUISizeHelper.scrollBarSize));
|
||||||
|
cardDimension = GUISizeHelper.battlefieldCardMaxDimension;
|
||||||
|
}
|
||||||
|
|
||||||
public void setTopPanelBattlefield(boolean topPanelBattlefield) {
|
public boolean isTopPanelBattlefield() {
|
||||||
this.topPanelBattlefield = topPanelBattlefield;
|
return topPanelBattlefield;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Map<UUID, PermanentView> battlefield) {
|
public void setTopPanelBattlefield(boolean topPanelBattlefield) {
|
||||||
boolean changed = false;
|
this.topPanelBattlefield = topPanelBattlefield;
|
||||||
|
}
|
||||||
|
|
||||||
List<PermanentView> permanentsToAdd = new ArrayList<>();
|
public void update(Map<UUID, PermanentView> battlefield) {
|
||||||
for (PermanentView permanent : battlefield.values()) {
|
boolean changed = false;
|
||||||
if (!permanent.isPhasedIn()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
MagePermanent oldMagePermanent = permanents.get(permanent.getId());
|
|
||||||
if (oldMagePermanent == null) {
|
|
||||||
permanentsToAdd.add(permanent);
|
|
||||||
changed = true;
|
|
||||||
} else {
|
|
||||||
if (!changed) {
|
|
||||||
changed = oldMagePermanent.getOriginalPermanent().isCreature() != permanent.isCreature();
|
|
||||||
// Check if there was a chnage in the permanets that are the permanent attached to
|
|
||||||
if (!changed) {
|
|
||||||
int attachments = permanent.getAttachments() == null ? 0 : permanent.getAttachments().size();
|
|
||||||
int attachmentsBefore = oldMagePermanent.getLinks().size();
|
|
||||||
if (attachments != attachmentsBefore) {
|
|
||||||
changed = true;
|
|
||||||
} else if (attachments > 0) {
|
|
||||||
Set<UUID> attachmentIds = new HashSet<>(permanent.getAttachments());
|
|
||||||
for (MagePermanent magePermanent : oldMagePermanent.getLinks()) {
|
|
||||||
if (!attachmentIds.contains(magePermanent.getOriginalPermanent().getId())) {
|
|
||||||
// that means that the amount of attachments is the same
|
|
||||||
// but they are different:
|
|
||||||
// we've just found an attachment on previous view
|
|
||||||
// that doesn't exist anymore on current view
|
|
||||||
changed = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Check if permanents it now attached to another or no permanent
|
|
||||||
if (!changed) {
|
|
||||||
UUID attachedToIdBefore = oldMagePermanent.getOriginalPermanent().getAttachedTo();
|
|
||||||
UUID attachedToId = permanent.getAttachedTo();
|
|
||||||
if (attachedToIdBefore == null && attachedToId != null || attachedToId == null && attachedToIdBefore != null
|
|
||||||
|| (attachedToIdBefore != null && !attachedToIdBefore.equals(attachedToId))) {
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Check for changes in the counters of the permanent
|
|
||||||
if (!changed) {
|
|
||||||
List<CounterView> counters1 = oldMagePermanent.getOriginalPermanent().getCounters();
|
|
||||||
List<CounterView> counters2 = permanent.getCounters();
|
|
||||||
if (counters1 == null && counters2 != null || counters1 != null && counters2 == null) {
|
|
||||||
changed = true;
|
|
||||||
} else if (counters1 != null && counters2 != null && counters1.size() != counters2.size()) {
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
List<PermanentView> permanentsToAdd = new ArrayList<>();
|
||||||
oldMagePermanent.update(permanent);
|
for (PermanentView permanent : battlefield.values()) {
|
||||||
}
|
if (!permanent.isPhasedIn()) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
MagePermanent oldMagePermanent = permanents.get(permanent.getId());
|
||||||
|
if (oldMagePermanent == null) {
|
||||||
|
permanentsToAdd.add(permanent);
|
||||||
|
changed = true;
|
||||||
|
} else {
|
||||||
|
if (!changed) {
|
||||||
|
changed = oldMagePermanent.getOriginalPermanent().isCreature() != permanent.isCreature();
|
||||||
|
// Check if there was a chnage in the permanets that are the permanent attached to
|
||||||
|
if (!changed) {
|
||||||
|
int attachments = permanent.getAttachments() == null ? 0 : permanent.getAttachments().size();
|
||||||
|
int attachmentsBefore = oldMagePermanent.getLinks().size();
|
||||||
|
if (attachments != attachmentsBefore) {
|
||||||
|
changed = true;
|
||||||
|
} else if (attachments > 0) {
|
||||||
|
Set<UUID> attachmentIds = new HashSet<>(permanent.getAttachments());
|
||||||
|
for (MagePermanent magePermanent : oldMagePermanent.getLinks()) {
|
||||||
|
if (!attachmentIds.contains(magePermanent.getOriginalPermanent().getId())) {
|
||||||
|
// that means that the amount of attachments is the same
|
||||||
|
// but they are different:
|
||||||
|
// we've just found an attachment on previous view
|
||||||
|
// that doesn't exist anymore on current view
|
||||||
|
changed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Check if permanents it now attached to another or no permanent
|
||||||
|
if (!changed) {
|
||||||
|
UUID attachedToIdBefore = oldMagePermanent.getOriginalPermanent().getAttachedTo();
|
||||||
|
UUID attachedToId = permanent.getAttachedTo();
|
||||||
|
if (attachedToIdBefore == null && attachedToId != null || attachedToId == null && attachedToIdBefore != null
|
||||||
|
|| (attachedToIdBefore != null && !attachedToIdBefore.equals(attachedToId))) {
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Check for changes in the counters of the permanent
|
||||||
|
if (!changed) {
|
||||||
|
List<CounterView> counters1 = oldMagePermanent.getOriginalPermanent().getCounters();
|
||||||
|
List<CounterView> counters2 = permanent.getCounters();
|
||||||
|
if (counters1 == null && counters2 != null || counters1 != null && counters2 == null) {
|
||||||
|
changed = true;
|
||||||
|
} else if (counters1 != null && counters2 != null && counters1.size() != counters2.size()) {
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addedArtifact = addedCreature = addedPermanent = false;
|
}
|
||||||
|
oldMagePermanent.update(permanent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int count = permanentsToAdd.size();
|
addedArtifact = addedCreature = addedPermanent = false;
|
||||||
for (PermanentView permanent : permanentsToAdd) {
|
|
||||||
addPermanent(permanent, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addedArtifact) {
|
int count = permanentsToAdd.size();
|
||||||
AudioManager.playAddArtifact();
|
for (PermanentView permanent : permanentsToAdd) {
|
||||||
} else if (addedCreature) {
|
addPermanent(permanent, count);
|
||||||
AudioManager.playSummon();
|
}
|
||||||
} else if (addedPermanent) {
|
|
||||||
AudioManager.playAddPermanent();
|
|
||||||
}
|
|
||||||
|
|
||||||
removedCreature = false;
|
if (addedArtifact) {
|
||||||
|
AudioManager.playAddArtifact();
|
||||||
|
} else if (addedCreature) {
|
||||||
|
AudioManager.playSummon();
|
||||||
|
} else if (addedPermanent) {
|
||||||
|
AudioManager.playAddPermanent();
|
||||||
|
}
|
||||||
|
|
||||||
for (Iterator<Entry<UUID, MagePermanent>> iterator = permanents.entrySet().iterator(); iterator.hasNext();) {
|
removedCreature = false;
|
||||||
Entry<UUID, MagePermanent> entry = iterator.next();
|
|
||||||
if (!battlefield.containsKey(entry.getKey()) || !battlefield.get(entry.getKey()).isPhasedIn()) {
|
|
||||||
removePermanent(entry.getKey(), 1);
|
|
||||||
iterator.remove();
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (removedCreature) {
|
for (Iterator<Entry<UUID, MagePermanent>> iterator = permanents.entrySet().iterator(); iterator.hasNext(); ) {
|
||||||
AudioManager.playDiedCreature();
|
Entry<UUID, MagePermanent> entry = iterator.next();
|
||||||
}
|
if (!battlefield.containsKey(entry.getKey()) || !battlefield.get(entry.getKey()).isPhasedIn()) {
|
||||||
|
removePermanent(entry.getKey(), 1);
|
||||||
|
iterator.remove();
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (removedCreature) {
|
||||||
this.battlefield = battlefield;
|
AudioManager.playDiedCreature();
|
||||||
sortLayout();
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sortLayout() {
|
if (changed) {
|
||||||
if (battlefield == null || this.getWidth() < 1) { // Can't do layout when panel is not sized yet
|
this.battlefield = battlefield;
|
||||||
return;
|
sortLayout();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
layoutStrategy.doLayout(this, width);
|
public void sortLayout() {
|
||||||
|
if (battlefield == null || this.getWidth() < 1) { // Can't do layout when panel is not sized yet
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.jScrollPane.repaint();
|
layoutStrategy.doLayout(this, width);
|
||||||
this.jScrollPane.revalidate();
|
|
||||||
|
|
||||||
invalidate();
|
this.jScrollPane.repaint();
|
||||||
repaint();
|
this.jScrollPane.revalidate();
|
||||||
}
|
|
||||||
|
|
||||||
private void addPermanent(PermanentView permanent, final int count) {
|
invalidate();
|
||||||
if (cardDimension == null) {
|
repaint();
|
||||||
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
|
}
|
||||||
}
|
|
||||||
final MagePermanent perm = Plugins.instance.getMagePermanent(permanent, bigCard, cardDimension, gameId, true);
|
|
||||||
|
|
||||||
permanents.put(permanent.getId(), perm);
|
private void addPermanent(PermanentView permanent, final int count) {
|
||||||
|
if (cardDimension == null) {
|
||||||
|
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
|
||||||
|
}
|
||||||
|
final MagePermanent perm = Plugins.instance.getMagePermanent(permanent, bigCard, cardDimension, gameId, true, PreferencesDialog.getRenderMode());
|
||||||
|
|
||||||
BattlefieldPanel.this.jPanel.add(perm, 10);
|
permanents.put(permanent.getId(), perm);
|
||||||
//this.jPanel.add(perm);
|
|
||||||
if (!Plugins.instance.isCardPluginLoaded()) {
|
BattlefieldPanel.this.jPanel.add(perm, 10);
|
||||||
moveToFront(perm);
|
//this.jPanel.add(perm);
|
||||||
perm.update(permanent);
|
if (!Plugins.instance.isCardPluginLoaded()) {
|
||||||
} else {
|
moveToFront(perm);
|
||||||
moveToFront(jPanel);
|
perm.update(permanent);
|
||||||
Plugins.instance.onAddCard(perm, 1);
|
} else {
|
||||||
|
moveToFront(jPanel);
|
||||||
|
Plugins.instance.onAddCard(perm, 1);
|
||||||
/*Thread t = new Thread(new Runnable() {
|
/*Thread t = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
@ -258,76 +249,76 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
threads.add(t);
|
threads.add(t);
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (permanent.isArtifact()) {
|
if (permanent.isArtifact()) {
|
||||||
addedArtifact = true;
|
addedArtifact = true;
|
||||||
} else if (permanent.isCreature()) {
|
} else if (permanent.isCreature()) {
|
||||||
addedCreature = true;
|
addedCreature = true;
|
||||||
} else {
|
} else {
|
||||||
addedPermanent = true;
|
addedPermanent = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removePermanent(UUID permanentId, final int count) {
|
private void removePermanent(UUID permanentId, final int count) {
|
||||||
for (Component c : this.jPanel.getComponents()) {
|
for (Component c : this.jPanel.getComponents()) {
|
||||||
final Component comp = c;
|
final Component comp = c;
|
||||||
if (comp instanceof Permanent) {
|
if (comp instanceof Permanent) {
|
||||||
if (((Permanent) comp).getPermanentId().equals(permanentId)) {
|
if (((Permanent) comp).getPermanentId().equals(permanentId)) {
|
||||||
comp.setVisible(false);
|
comp.setVisible(false);
|
||||||
this.jPanel.remove(comp);
|
this.jPanel.remove(comp);
|
||||||
}
|
}
|
||||||
} else if (comp instanceof MagePermanent) {
|
} else if (comp instanceof MagePermanent) {
|
||||||
if (((MagePermanent) comp).getOriginal().getId().equals(permanentId)) {
|
if (((MagePermanent) comp).getOriginal().getId().equals(permanentId)) {
|
||||||
Thread t = new Thread(() -> {
|
Thread t = new Thread(() -> {
|
||||||
Plugins.instance.onRemoveCard((MagePermanent) comp, count);
|
Plugins.instance.onRemoveCard((MagePermanent) comp, count);
|
||||||
comp.setVisible(false);
|
comp.setVisible(false);
|
||||||
BattlefieldPanel.this.jPanel.remove(comp);
|
BattlefieldPanel.this.jPanel.remove(comp);
|
||||||
});
|
});
|
||||||
t.start();
|
t.start();
|
||||||
}
|
}
|
||||||
if (((MagePermanent) comp).getOriginal().isCreature()) {
|
if (((MagePermanent) comp).getOriginal().isCreature()) {
|
||||||
removedCreature = true;
|
removedCreature = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOptimizedDrawingEnabled() {
|
public boolean isOptimizedDrawingEnabled() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<UUID, MagePermanent> getPermanents() {
|
public Map<UUID, MagePermanent> getPermanents() {
|
||||||
return permanents;
|
return permanents;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
setOpaque(false);
|
setOpaque(false);
|
||||||
|
|
||||||
jPanel = new JLayeredPane();
|
jPanel = new JLayeredPane();
|
||||||
jPanel.setLayout(null);
|
jPanel.setLayout(null);
|
||||||
jPanel.setOpaque(false);
|
jPanel.setOpaque(false);
|
||||||
jScrollPane = new JScrollPane(jPanel);
|
jScrollPane = new JScrollPane(jPanel);
|
||||||
|
|
||||||
Border empty = new EmptyBorder(0, 0, 0, 0);
|
Border empty = new EmptyBorder(0, 0, 0, 0);
|
||||||
jScrollPane.setBorder(empty);
|
jScrollPane.setBorder(empty);
|
||||||
jScrollPane.setViewportBorder(empty);
|
jScrollPane.setViewportBorder(empty);
|
||||||
jScrollPane.setOpaque(false);
|
jScrollPane.setOpaque(false);
|
||||||
jScrollPane.getViewport().setOpaque(false);
|
jScrollPane.getViewport().setOpaque(false);
|
||||||
|
|
||||||
this.add(jScrollPane);
|
this.add(jScrollPane);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JLayeredPane getMainPanel() {
|
public JLayeredPane getMainPanel() {
|
||||||
return jPanel;
|
return jPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<UUID, PermanentView> getBattlefield() {
|
public Map<UUID, PermanentView> getBattlefield() {
|
||||||
return battlefield;
|
return battlefield;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, JComponent> getUiComponentsList() {
|
public Map<String, JComponent> getUiComponentsList() {
|
||||||
return uiComponentsList;
|
return uiComponentsList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,5 @@
|
||||||
package mage.client.plugins;
|
package mage.client.plugins;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import javax.swing.*;
|
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
import mage.cards.MagePermanent;
|
import mage.cards.MagePermanent;
|
||||||
import mage.cards.action.ActionCallback;
|
import mage.cards.action.ActionCallback;
|
||||||
|
|
@ -12,6 +7,12 @@ import mage.client.cards.BigCard;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
import mage.view.PermanentView;
|
import mage.view.PermanentView;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface MagePlugins {
|
public interface MagePlugins {
|
||||||
|
|
||||||
void loadPlugins();
|
void loadPlugins();
|
||||||
|
|
@ -22,9 +23,9 @@ public interface MagePlugins {
|
||||||
|
|
||||||
JComponent updateTablePanel(Map<String, JComponent> ui);
|
JComponent updateTablePanel(Map<String, JComponent> ui);
|
||||||
|
|
||||||
MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage);
|
MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage, int renderMode);
|
||||||
|
|
||||||
MageCard getMageCard(CardView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage, boolean previewable);
|
MageCard getMageCard(CardView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage, boolean previewable, int renderMode);
|
||||||
|
|
||||||
boolean isThemePluginLoaded();
|
boolean isThemePluginLoaded();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,5 @@
|
||||||
package mage.client.plugins.impl;
|
package mage.client.plugins.impl;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
import mage.cards.MagePermanent;
|
import mage.cards.MagePermanent;
|
||||||
import mage.cards.action.ActionCallback;
|
import mage.cards.action.ActionCallback;
|
||||||
|
|
@ -27,12 +20,20 @@ import mage.view.PermanentView;
|
||||||
import net.xeoh.plugins.base.PluginManager;
|
import net.xeoh.plugins.base.PluginManager;
|
||||||
import net.xeoh.plugins.base.impl.PluginManagerFactory;
|
import net.xeoh.plugins.base.impl.PluginManagerFactory;
|
||||||
import net.xeoh.plugins.base.util.uri.ClassURI;
|
import net.xeoh.plugins.base.util.uri.ClassURI;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.mage.plugins.card.CardPluginImpl;
|
import org.mage.plugins.card.CardPluginImpl;
|
||||||
import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
|
|
||||||
import org.mage.plugins.theme.ThemePluginImpl;
|
import org.mage.plugins.theme.ThemePluginImpl;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
|
||||||
|
|
||||||
public enum Plugins implements MagePlugins {
|
public enum Plugins implements MagePlugins {
|
||||||
instance;
|
instance;
|
||||||
public static final String PLUGINS_DIRECTORY = "plugins";
|
public static final String PLUGINS_DIRECTORY = "plugins";
|
||||||
|
|
@ -92,24 +93,24 @@ public enum Plugins implements MagePlugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage) {
|
public MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage, int renderMode) {
|
||||||
if (cardPlugin != null) {
|
if (cardPlugin != null) {
|
||||||
mageActionCallback.refreshSession();
|
mageActionCallback.refreshSession();
|
||||||
mageActionCallback.setCardPreviewComponent(bigCard);
|
mageActionCallback.setCardPreviewComponent(bigCard);
|
||||||
return cardPlugin.getMagePermanent(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage);
|
return cardPlugin.getMagePermanent(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage, renderMode);
|
||||||
} else {
|
} else {
|
||||||
return new Permanent(card, bigCard, Config.dimensions, gameId);
|
return new Permanent(card, bigCard, Config.dimensions, gameId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MageCard getMageCard(CardView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage, boolean previewable) {
|
public MageCard getMageCard(CardView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage, boolean previewable, int renderMode) {
|
||||||
if (cardPlugin != null) {
|
if (cardPlugin != null) {
|
||||||
if (previewable) {
|
if (previewable) {
|
||||||
mageActionCallback.refreshSession();
|
mageActionCallback.refreshSession();
|
||||||
mageActionCallback.setCardPreviewComponent(bigCard);
|
mageActionCallback.setCardPreviewComponent(bigCard);
|
||||||
}
|
}
|
||||||
return cardPlugin.getMageCard(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage);
|
return cardPlugin.getMageCard(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage, renderMode);
|
||||||
} else {
|
} else {
|
||||||
return new Card(card, bigCard, Config.dimensions, gameId);
|
return new Card(card, bigCard, Config.dimensions, gameId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package org.mage.plugins.card;
|
||||||
|
|
||||||
import mage.cards.MagePermanent;
|
import mage.cards.MagePermanent;
|
||||||
import mage.cards.action.ActionCallback;
|
import mage.cards.action.ActionCallback;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
|
||||||
import mage.client.util.GUISizeHelper;
|
import mage.client.util.GUISizeHelper;
|
||||||
import mage.interfaces.plugin.CardPlugin;
|
import mage.interfaces.plugin.CardPlugin;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
|
|
@ -99,25 +98,28 @@ public class CardPluginImpl implements CardPlugin {
|
||||||
* Temporary card rendering shim. Split card rendering isn't implemented
|
* Temporary card rendering shim. Split card rendering isn't implemented
|
||||||
* yet, so use old component based rendering for the split cards.
|
* yet, so use old component based rendering for the split cards.
|
||||||
*/
|
*/
|
||||||
private CardPanel makePanel(CardView view, UUID gameId, boolean loadImage, ActionCallback callback, boolean isFoil, Dimension dimension) {
|
private CardPanel makePanel(CardView view, UUID gameId, boolean loadImage, ActionCallback callback, boolean isFoil, Dimension dimension, int renderMode) {
|
||||||
String fallback = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_FALLBACK, "false");
|
switch (renderMode) {
|
||||||
if (fallback.equals("true")) {
|
case 0:
|
||||||
return new CardPanelComponentImpl(view, gameId, loadImage, callback, isFoil, dimension);
|
return new CardPanelRenderImpl(view, gameId, loadImage, callback, isFoil, dimension);
|
||||||
} else {
|
case 1:
|
||||||
return new CardPanelRenderImpl(view, gameId, loadImage, callback, isFoil, dimension);
|
return new CardPanelComponentImpl(view, gameId, loadImage, callback, isFoil, dimension);
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException("Unknown render mode " + renderMode);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage) {
|
public MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage, int renderMode) {
|
||||||
CardPanel cardPanel = makePanel(permanent, gameId, loadImage, callback, false, dimension);
|
CardPanel cardPanel = makePanel(permanent, gameId, loadImage, callback, false, dimension, renderMode);
|
||||||
cardPanel.setShowCastingCost(true);
|
cardPanel.setShowCastingCost(true);
|
||||||
return cardPanel;
|
return cardPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MagePermanent getMageCard(CardView cardView, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage) {
|
public MagePermanent getMageCard(CardView cardView, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage, int renderMode) {
|
||||||
CardPanel cardPanel = makePanel(cardView, gameId, loadImage, callback, false, dimension);
|
CardPanel cardPanel = makePanel(cardView, gameId, loadImage, callback, false, dimension, renderMode);
|
||||||
cardPanel.setShowCastingCost(true);
|
cardPanel.setShowCastingCost(true);
|
||||||
return cardPanel;
|
return cardPanel;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,28 @@
|
||||||
package mage.interfaces.plugin;
|
package mage.interfaces.plugin;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import javax.swing.*;
|
|
||||||
import mage.cards.MagePermanent;
|
import mage.cards.MagePermanent;
|
||||||
import mage.cards.action.ActionCallback;
|
import mage.cards.action.ActionCallback;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
import mage.view.PermanentView;
|
import mage.view.PermanentView;
|
||||||
import net.xeoh.plugins.base.Plugin;
|
import net.xeoh.plugins.base.Plugin;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for card plugins
|
* Interface for card plugins
|
||||||
*
|
*
|
||||||
* @version 0.6 17.07.2011 added options to #sortPermanents
|
|
||||||
* @version 0.3 21.11.2010 #getMageCard
|
|
||||||
* @version 0.2 07.11.2010 #downloadImages
|
|
||||||
* @version 0.1 31.10.2010 #getMagePermanent, #sortPermanents
|
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
|
* @version 0.1 31.10.2010 #getMagePermanent, #sortPermanents
|
||||||
*/
|
*/
|
||||||
public interface CardPlugin extends Plugin {
|
public interface CardPlugin extends Plugin {
|
||||||
|
|
||||||
MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage);
|
MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage, int renderMode);
|
||||||
|
|
||||||
MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage);
|
MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage, int renderMode);
|
||||||
|
|
||||||
int sortPermanents(Map<String, JComponent> ui, Map<UUID, MagePermanent> cards, boolean nonPermanentsOwnRow, boolean topPanel);
|
int sortPermanents(Map<String, JComponent> ui, Map<UUID, MagePermanent> cards, boolean nonPermanentsOwnRow, boolean topPanel);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue