mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00: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;
|
||||
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.ClientEventType;
|
||||
import mage.client.util.Event;
|
||||
|
@ -30,6 +31,9 @@ public class CardArea extends JPanel implements MouseListener {
|
|||
private Dimension cardDimension;
|
||||
private int verticalCardOffset;
|
||||
|
||||
private int customRenderMode = -1; // custom render mode tests
|
||||
private Dimension customCardSize = null; // custom size for tests
|
||||
|
||||
/**
|
||||
* Create the panel.
|
||||
*/
|
||||
|
@ -62,7 +66,11 @@ public class CardArea extends JPanel implements MouseListener {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -129,7 +137,8 @@ public class CardArea extends JPanel implements MouseListener {
|
|||
tmp.setAbility(card); // cross-reference, required for ability picker
|
||||
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.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
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package mage.client.cards;
|
|||
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.MagePane;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.view.CardView;
|
||||
|
||||
|
@ -45,7 +46,7 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
|
|||
currentRoot = SwingUtilities.getRootPane(c);
|
||||
|
||||
// Pane
|
||||
glassPane = (JComponent)currentRoot.getGlassPane();
|
||||
glassPane = (JComponent) currentRoot.getGlassPane();
|
||||
glassPane.setLayout(null);
|
||||
glassPane.setOpaque(false);
|
||||
glassPane.setVisible(true);
|
||||
|
@ -58,7 +59,7 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
|
|||
if (rootMagePane == null) {
|
||||
throw new RuntimeException("CardDraggerGlassPane::beginDrag not in a MagePane?");
|
||||
} else {
|
||||
currentEventRootMagePane = (MagePane)rootMagePane;
|
||||
currentEventRootMagePane = (MagePane) rootMagePane;
|
||||
}
|
||||
|
||||
// Hook up events
|
||||
|
@ -72,8 +73,8 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
|
|||
currentCards = new ArrayList<>(source.dragCardList());
|
||||
|
||||
// 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);
|
||||
for (MouseListener l: dragView.getMouseListeners()) {
|
||||
dragView = Plugins.instance.getMageCard(currentCards.get(0), null, new Dimension(100, 140), null, true, false, PreferencesDialog.getRenderMode());
|
||||
for (MouseListener l : dragView.getMouseListeners()) {
|
||||
dragView.removeMouseListener(l);
|
||||
}
|
||||
for (MouseMotionListener l : dragView.getMouseMotionListeners()) {
|
||||
|
@ -95,7 +96,7 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
|
|||
Component mouseOver = SwingUtilities.getDeepestComponentAt(currentEventRootMagePane, e.getX(), e.getY());
|
||||
while (mouseOver != null) {
|
||||
if (mouseOver instanceof DragCardTarget) {
|
||||
DragCardTarget target = (DragCardTarget)mouseOver;
|
||||
DragCardTarget target = (DragCardTarget) mouseOver;
|
||||
MouseEvent targetEvent = SwingUtilities.convertMouseEvent(currentEventRootMagePane, e, mouseOver);
|
||||
if (target != currentDragTarget) {
|
||||
if (currentDragTarget != null) {
|
||||
|
@ -116,7 +117,7 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
|
|||
mouseOver = mouseOver.getParent();
|
||||
}
|
||||
if (currentDragTarget != null) {
|
||||
MouseEvent oldTargetEvent = SwingUtilities.convertMouseEvent(currentEventRootMagePane, e, (Component)currentDragTarget);
|
||||
MouseEvent oldTargetEvent = SwingUtilities.convertMouseEvent(currentEventRootMagePane, e, (Component) currentDragTarget);
|
||||
currentDragTarget.dragCardExit(oldTargetEvent);
|
||||
}
|
||||
currentDragTarget = null;
|
||||
|
@ -164,13 +165,22 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
|
|||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {}
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {}
|
||||
public void mousePressed(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {}
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {}
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {}
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,430 +1,430 @@
|
|||
|
||||
|
||||
/*
|
||||
* CardGrid.java
|
||||
*
|
||||
* Created on 30-Mar-2010, 9:25:40 PM
|
||||
*/
|
||||
package mage.client.cards;
|
||||
* CardGrid.java
|
||||
*
|
||||
* Created on 30-Mar-2010, 9:25:40 PM
|
||||
*/
|
||||
package mage.client.cards;
|
||||
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.deckeditor.SortSetting;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.ClientEventType;
|
||||
import mage.client.util.Event;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
import mage.client.util.Listener;
|
||||
import mage.utils.CardColorUtil;
|
||||
import mage.view.CardView;
|
||||
import mage.view.CardsView;
|
||||
import org.mage.card.arcane.CardPanel;
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.deckeditor.SortSetting;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.ClientEventType;
|
||||
import mage.client.util.Event;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
import mage.client.util.Listener;
|
||||
import mage.utils.CardColorUtil;
|
||||
import mage.view.CardView;
|
||||
import mage.view.CardsView;
|
||||
import org.mage.card.arcane.CardPanel;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CardGrid extends javax.swing.JLayeredPane implements MouseListener, ICardGrid {
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CardGrid extends javax.swing.JLayeredPane implements MouseListener, ICardGrid {
|
||||
|
||||
protected final CardEventSource cardEventSource = new CardEventSource();
|
||||
protected BigCard bigCard;
|
||||
protected UUID gameId;
|
||||
private final Map<UUID, MageCard> cards = new HashMap<>();
|
||||
private Dimension cardDimension;
|
||||
protected final CardEventSource cardEventSource = new CardEventSource();
|
||||
protected BigCard bigCard;
|
||||
protected UUID gameId;
|
||||
private final Map<UUID, MageCard> cards = new HashMap<>();
|
||||
private Dimension cardDimension;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public static final int MAX_IMAGES = 350;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public static final int MAX_IMAGES = 350;
|
||||
|
||||
public CardGrid() {
|
||||
initComponents();
|
||||
setGUISize();
|
||||
setOpaque(false);
|
||||
}
|
||||
public CardGrid() {
|
||||
initComponents();
|
||||
setGUISize();
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
for (MouseListener ml : this.getMouseListeners()) {
|
||||
this.removeMouseListener(ml);
|
||||
}
|
||||
this.clearCardEventListeners();
|
||||
this.clearCards();
|
||||
this.bigCard = null;
|
||||
}
|
||||
public void clear() {
|
||||
for (MouseListener ml : this.getMouseListeners()) {
|
||||
this.removeMouseListener(ml);
|
||||
}
|
||||
this.clearCardEventListeners();
|
||||
this.clearCards();
|
||||
this.bigCard = null;
|
||||
}
|
||||
|
||||
public void changeGUISize() {
|
||||
setGUISize();
|
||||
}
|
||||
public void changeGUISize() {
|
||||
setGUISize();
|
||||
}
|
||||
|
||||
private void setGUISize() {
|
||||
cardDimension = GUISizeHelper.editorCardDimension;
|
||||
}
|
||||
private void setGUISize() {
|
||||
cardDimension = GUISizeHelper.editorCardDimension;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCards(CardsView showCards, SortSetting sortSetting, BigCard bigCard, UUID gameId) {
|
||||
this.loadCards(showCards, sortSetting, bigCard, gameId, true);
|
||||
}
|
||||
@Override
|
||||
public void loadCards(CardsView showCards, SortSetting sortSetting, BigCard bigCard, UUID gameId) {
|
||||
this.loadCards(showCards, sortSetting, bigCard, gameId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCards(CardsView showCards, SortSetting sortSetting, BigCard bigCard, UUID gameId, boolean merge) {
|
||||
boolean drawImage = showCards.size() <= MAX_IMAGES;
|
||||
this.bigCard = bigCard;
|
||||
this.gameId = gameId;
|
||||
if (merge) {
|
||||
for (CardView card : showCards.values()) {
|
||||
if (!cards.containsKey(card.getId())) {
|
||||
addCard(card, bigCard, gameId, drawImage);
|
||||
}
|
||||
}
|
||||
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) {
|
||||
Entry<UUID, MageCard> entry = i.next();
|
||||
if (!showCards.containsKey(entry.getKey())) {
|
||||
removeCardImg(entry.getKey());
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.clearCards();
|
||||
for (CardView card : showCards.values()) {
|
||||
addCard(card, bigCard, gameId, drawImage);
|
||||
}
|
||||
}
|
||||
drawCards(sortSetting);
|
||||
this.setVisible(true);
|
||||
}
|
||||
@Override
|
||||
public void loadCards(CardsView showCards, SortSetting sortSetting, BigCard bigCard, UUID gameId, boolean merge) {
|
||||
boolean drawImage = showCards.size() <= MAX_IMAGES;
|
||||
this.bigCard = bigCard;
|
||||
this.gameId = gameId;
|
||||
if (merge) {
|
||||
for (CardView card : showCards.values()) {
|
||||
if (!cards.containsKey(card.getId())) {
|
||||
addCard(card, bigCard, gameId, drawImage);
|
||||
}
|
||||
}
|
||||
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext(); ) {
|
||||
Entry<UUID, MageCard> entry = i.next();
|
||||
if (!showCards.containsKey(entry.getKey())) {
|
||||
removeCardImg(entry.getKey());
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.clearCards();
|
||||
for (CardView card : showCards.values()) {
|
||||
addCard(card, bigCard, gameId, drawImage);
|
||||
}
|
||||
}
|
||||
drawCards(sortSetting);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, boolean drawImage) {
|
||||
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, drawImage, true);
|
||||
cards.put(card.getId(), cardImg);
|
||||
cardImg.addMouseListener(this);
|
||||
add(cardImg);
|
||||
cardImg.update(card);
|
||||
cards.put(card.getId(), cardImg);
|
||||
}
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, boolean drawImage) {
|
||||
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, drawImage, true, PreferencesDialog.getRenderMode());
|
||||
cards.put(card.getId(), cardImg);
|
||||
cardImg.addMouseListener(this);
|
||||
add(cardImg);
|
||||
cardImg.update(card);
|
||||
cards.put(card.getId(), cardImg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawCards(SortSetting sortSetting) {
|
||||
int maxWidth = this.getParent().getWidth();
|
||||
int cardVerticalOffset = GUISizeHelper.editorCardOffsetSize;
|
||||
int numColumns = maxWidth / cardDimension.width;
|
||||
int curColumn = 0;
|
||||
int curRow = 0;
|
||||
if (!cards.isEmpty()) {
|
||||
Rectangle rectangle = new Rectangle(cardDimension.width, cardDimension.height);
|
||||
List<MageCard> sortedCards = new ArrayList<>(cards.values());
|
||||
switch (sortSetting.getSortBy()) {
|
||||
case NAME:
|
||||
sortedCards.sort(new CardNameComparator());
|
||||
break;
|
||||
case CARD_TYPE:
|
||||
sortedCards.sort(new CardTypeComparator());
|
||||
break;
|
||||
case RARITY:
|
||||
sortedCards.sort(new CardRarityComparator());
|
||||
break;
|
||||
case COLOR:
|
||||
sortedCards.sort(new CardColorComparator());
|
||||
break;
|
||||
case COLOR_IDENTITY:
|
||||
sortedCards.sort(new CardColorDetailedIdentity());
|
||||
break;
|
||||
case CASTING_COST:
|
||||
sortedCards.sort(new CardCostComparator());
|
||||
break;
|
||||
@Override
|
||||
public void drawCards(SortSetting sortSetting) {
|
||||
int maxWidth = this.getParent().getWidth();
|
||||
int cardVerticalOffset = GUISizeHelper.editorCardOffsetSize;
|
||||
int numColumns = maxWidth / cardDimension.width;
|
||||
int curColumn = 0;
|
||||
int curRow = 0;
|
||||
if (!cards.isEmpty()) {
|
||||
Rectangle rectangle = new Rectangle(cardDimension.width, cardDimension.height);
|
||||
List<MageCard> sortedCards = new ArrayList<>(cards.values());
|
||||
switch (sortSetting.getSortBy()) {
|
||||
case NAME:
|
||||
sortedCards.sort(new CardNameComparator());
|
||||
break;
|
||||
case CARD_TYPE:
|
||||
sortedCards.sort(new CardTypeComparator());
|
||||
break;
|
||||
case RARITY:
|
||||
sortedCards.sort(new CardRarityComparator());
|
||||
break;
|
||||
case COLOR:
|
||||
sortedCards.sort(new CardColorComparator());
|
||||
break;
|
||||
case COLOR_IDENTITY:
|
||||
sortedCards.sort(new CardColorDetailedIdentity());
|
||||
break;
|
||||
case CASTING_COST:
|
||||
sortedCards.sort(new CardCostComparator());
|
||||
break;
|
||||
|
||||
}
|
||||
MageCard lastCard = null;
|
||||
for (MageCard cardImg : sortedCards) {
|
||||
if (sortSetting.isPilesToggle()) {
|
||||
if (lastCard == null) {
|
||||
lastCard = cardImg;
|
||||
}
|
||||
switch (sortSetting.getSortBy()) {
|
||||
case NAME:
|
||||
if (!cardImg.getOriginal().getName().equals(lastCard.getOriginal().getName())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case CARD_TYPE:
|
||||
if (!cardImg.getOriginal().getCardTypes().equals(lastCard.getOriginal().getCardTypes())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case RARITY:
|
||||
if (cardImg.getOriginal().getRarity() != lastCard.getOriginal().getRarity()) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case COLOR:
|
||||
if (cardImg.getOriginal().getColor().compareTo(lastCard.getOriginal().getColor()) != 0) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case COLOR_IDENTITY:
|
||||
if (CardColorUtil.getColorIdentitySortValue(cardImg.getOriginal().getManaCost(), cardImg.getOriginal().getColor(), cardImg.getOriginal().getRules())
|
||||
!= CardColorUtil.getColorIdentitySortValue(lastCard.getOriginal().getManaCost(), lastCard.getOriginal().getColor(), lastCard.getOriginal().getRules())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case CASTING_COST:
|
||||
if (cardImg.getOriginal().getConvertedManaCost() != lastCard.getOriginal().getConvertedManaCost()) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
rectangle.setLocation(curColumn * cardDimension.width, curRow * cardVerticalOffset);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimension.width, cardDimension.height);
|
||||
moveToFront(cardImg);
|
||||
curRow++;
|
||||
lastCard = cardImg;
|
||||
} else {
|
||||
rectangle.setLocation(curColumn * cardDimension.width, curRow * cardVerticalOffset);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimension.width, cardDimension.height);
|
||||
moveToFront(cardImg);
|
||||
curColumn++;
|
||||
if (curColumn == numColumns) {
|
||||
curColumn = 0;
|
||||
curRow++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resizeArea();
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
MageCard lastCard = null;
|
||||
for (MageCard cardImg : sortedCards) {
|
||||
if (sortSetting.isPilesToggle()) {
|
||||
if (lastCard == null) {
|
||||
lastCard = cardImg;
|
||||
}
|
||||
switch (sortSetting.getSortBy()) {
|
||||
case NAME:
|
||||
if (!cardImg.getOriginal().getName().equals(lastCard.getOriginal().getName())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case CARD_TYPE:
|
||||
if (!cardImg.getOriginal().getCardTypes().equals(lastCard.getOriginal().getCardTypes())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case RARITY:
|
||||
if (cardImg.getOriginal().getRarity() != lastCard.getOriginal().getRarity()) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case COLOR:
|
||||
if (cardImg.getOriginal().getColor().compareTo(lastCard.getOriginal().getColor()) != 0) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case COLOR_IDENTITY:
|
||||
if (CardColorUtil.getColorIdentitySortValue(cardImg.getOriginal().getManaCost(), cardImg.getOriginal().getColor(), cardImg.getOriginal().getRules())
|
||||
!= CardColorUtil.getColorIdentitySortValue(lastCard.getOriginal().getManaCost(), lastCard.getOriginal().getColor(), lastCard.getOriginal().getRules())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case CASTING_COST:
|
||||
if (cardImg.getOriginal().getConvertedManaCost() != lastCard.getOriginal().getConvertedManaCost()) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
rectangle.setLocation(curColumn * cardDimension.width, curRow * cardVerticalOffset);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimension.width, cardDimension.height);
|
||||
moveToFront(cardImg);
|
||||
curRow++;
|
||||
lastCard = cardImg;
|
||||
} else {
|
||||
rectangle.setLocation(curColumn * cardDimension.width, curRow * cardVerticalOffset);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimension.width, cardDimension.height);
|
||||
moveToFront(cardImg);
|
||||
curColumn++;
|
||||
if (curColumn == numColumns) {
|
||||
curColumn = 0;
|
||||
curRow++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resizeArea();
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void clearCards() {
|
||||
// remove possible mouse listeners, preventing gc
|
||||
for (MageCard mageCard : cards.values()) {
|
||||
if (mageCard instanceof CardPanel) {
|
||||
((CardPanel) mageCard).cleanUp();
|
||||
}
|
||||
}
|
||||
this.cards.clear();
|
||||
removeAllCardImg();
|
||||
}
|
||||
private void clearCards() {
|
||||
// remove possible mouse listeners, preventing gc
|
||||
for (MageCard mageCard : cards.values()) {
|
||||
if (mageCard instanceof CardPanel) {
|
||||
((CardPanel) mageCard).cleanUp();
|
||||
}
|
||||
}
|
||||
this.cards.clear();
|
||||
removeAllCardImg();
|
||||
}
|
||||
|
||||
private void removeAllCardImg() {
|
||||
for (Component comp : getComponents()) {
|
||||
if (comp instanceof Card || comp instanceof MageCard) {
|
||||
remove(comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void removeAllCardImg() {
|
||||
for (Component comp : getComponents()) {
|
||||
if (comp instanceof Card || comp instanceof MageCard) {
|
||||
remove(comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeCardImg(UUID cardId) {
|
||||
for (Component comp : getComponents()) {
|
||||
if (comp instanceof Card) {
|
||||
if (((Card) comp).getCardId().equals(cardId)) {
|
||||
remove(comp);
|
||||
comp = null;
|
||||
}
|
||||
} else if (comp instanceof MageCard) {
|
||||
if (((MageCard) comp).getOriginal().getId().equals(cardId)) {
|
||||
remove(comp);
|
||||
comp = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void removeCardImg(UUID cardId) {
|
||||
for (Component comp : getComponents()) {
|
||||
if (comp instanceof Card) {
|
||||
if (((Card) comp).getCardId().equals(cardId)) {
|
||||
remove(comp);
|
||||
comp = null;
|
||||
}
|
||||
} else if (comp instanceof MageCard) {
|
||||
if (((MageCard) comp).getOriginal().getId().equals(cardId)) {
|
||||
remove(comp);
|
||||
comp = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeCard(UUID cardId) {
|
||||
removeCardImg(cardId);
|
||||
cards.remove(cardId);
|
||||
}
|
||||
public void removeCard(UUID cardId) {
|
||||
removeCardImg(cardId);
|
||||
cards.remove(cardId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCardEventListener(Listener<Event> listener) {
|
||||
cardEventSource.addListener(listener);
|
||||
}
|
||||
@Override
|
||||
public void addCardEventListener(Listener<Event> listener) {
|
||||
cardEventSource.addListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCardEventListeners() {
|
||||
cardEventSource.clearListeners();
|
||||
}
|
||||
@Override
|
||||
public void clearCardEventListeners() {
|
||||
cardEventSource.clearListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 294, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 197, Short.MAX_VALUE)
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 294, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 197, Short.MAX_VALUE)
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if ((e.getClickCount() & 1) == 0 && (e.getClickCount() > 0) && !e.isConsumed()) { // double clicks and repeated double clicks
|
||||
e.consume();
|
||||
Object obj = e.getSource();
|
||||
if (obj instanceof Card) {
|
||||
if (e.isAltDown()) {
|
||||
cardEventSource.fireEvent(((Card) obj).getOriginal(), ClientEventType.ALT_DOUBLE_CLICK);
|
||||
} else {
|
||||
cardEventSource.fireEvent(((Card) obj).getOriginal(), ClientEventType.DOUBLE_CLICK);
|
||||
}
|
||||
} else if (obj instanceof MageCard) {
|
||||
if (e.isAltDown()) {
|
||||
cardEventSource.fireEvent(((MageCard) obj).getOriginal(), ClientEventType.ALT_DOUBLE_CLICK);
|
||||
} else {
|
||||
cardEventSource.fireEvent(((MageCard) obj).getOriginal(), ClientEventType.DOUBLE_CLICK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if ((e.getClickCount() & 1) == 0 && (e.getClickCount() > 0) && !e.isConsumed()) { // double clicks and repeated double clicks
|
||||
e.consume();
|
||||
Object obj = e.getSource();
|
||||
if (obj instanceof Card) {
|
||||
if (e.isAltDown()) {
|
||||
cardEventSource.fireEvent(((Card) obj).getOriginal(), ClientEventType.ALT_DOUBLE_CLICK);
|
||||
} else {
|
||||
cardEventSource.fireEvent(((Card) obj).getOriginal(), ClientEventType.DOUBLE_CLICK);
|
||||
}
|
||||
} else if (obj instanceof MageCard) {
|
||||
if (e.isAltDown()) {
|
||||
cardEventSource.fireEvent(((MageCard) obj).getOriginal(), ClientEventType.ALT_DOUBLE_CLICK);
|
||||
} else {
|
||||
cardEventSource.fireEvent(((MageCard) obj).getOriginal(), ClientEventType.DOUBLE_CLICK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
private void resizeArea() {
|
||||
Dimension area = new Dimension(0, 0);
|
||||
Dimension size = getPreferredSize();
|
||||
private void resizeArea() {
|
||||
Dimension area = new Dimension(0, 0);
|
||||
Dimension size = getPreferredSize();
|
||||
|
||||
for (Component comp : getComponents()) {
|
||||
Rectangle r = comp.getBounds();
|
||||
if (r.x + r.width > area.width) {
|
||||
area.width = r.x + r.width;
|
||||
}
|
||||
if (r.y + r.height > area.height) {
|
||||
area.height = r.y + r.height;
|
||||
}
|
||||
}
|
||||
if (size.height != area.height || size.width != area.width) {
|
||||
setPreferredSize(area);
|
||||
}
|
||||
}
|
||||
for (Component comp : getComponents()) {
|
||||
Rectangle r = comp.getBounds();
|
||||
if (r.x + r.width > area.width) {
|
||||
area.width = r.x + r.width;
|
||||
}
|
||||
if (r.y + r.height > area.height) {
|
||||
area.height = r.y + r.height;
|
||||
}
|
||||
}
|
||||
if (size.height != area.height || size.width != area.width) {
|
||||
setPreferredSize(area);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
@Override
|
||||
public void refresh() {
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cardsSize() {
|
||||
return cards.size();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int cardsSize() {
|
||||
return cards.size();
|
||||
}
|
||||
}
|
||||
|
||||
class CardNameComparator implements Comparator<MageCard> {
|
||||
class CardNameComparator implements Comparator<MageCard> {
|
||||
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
}
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class CardRarityComparator implements Comparator<MageCard> {
|
||||
class CardRarityComparator implements Comparator<MageCard> {
|
||||
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = o1.getOriginal().getRarity().compareTo(o2.getOriginal().getRarity());
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = o1.getOriginal().getRarity().compareTo(o2.getOriginal().getRarity());
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class CardCostComparator implements Comparator<MageCard> {
|
||||
class CardCostComparator implements Comparator<MageCard> {
|
||||
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(o2.getOriginal().getConvertedManaCost());
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(o2.getOriginal().getConvertedManaCost());
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class CardColorComparator implements Comparator<MageCard> {
|
||||
class CardColorComparator implements Comparator<MageCard> {
|
||||
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = o1.getOriginal().getColor().compareTo(o2.getOriginal().getColor());
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = o1.getOriginal().getColor().compareTo(o2.getOriginal().getColor());
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class CardColorDetailedIdentity implements Comparator<MageCard> {
|
||||
class CardColorDetailedIdentity implements Comparator<MageCard> {
|
||||
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = CardColorUtil.getColorIdentitySortValue(o1.getOriginal().getManaCost(), o1.getOriginal().getColor(), o1.getOriginal().getRules())
|
||||
- CardColorUtil.getColorIdentitySortValue(o2.getOriginal().getManaCost(), o2.getOriginal().getColor(), o2.getOriginal().getRules());
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = CardColorUtil.getColorIdentitySortValue(o1.getOriginal().getManaCost(), o1.getOriginal().getColor(), o1.getOriginal().getRules())
|
||||
- CardColorUtil.getColorIdentitySortValue(o2.getOriginal().getManaCost(), o2.getOriginal().getColor(), o2.getOriginal().getRules());
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class CardTypeComparator implements Comparator<MageCard> {
|
||||
class CardTypeComparator implements Comparator<MageCard> {
|
||||
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = o1.getOriginal().getCardTypes().toString().compareTo(o2.getOriginal().getCardTypes().toString());
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = o1.getOriginal().getCardTypes().toString().compareTo(o2.getOriginal().getCardTypes().toString());
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
package mage.client.cards;
|
||||
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.CardsViewUtil;
|
||||
import mage.client.util.Config;
|
||||
|
@ -227,7 +228,7 @@
|
|||
}
|
||||
|
||||
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) {
|
||||
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.MageCard;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.CardViewRarityComparator;
|
||||
import mage.client.util.ClientEventType;
|
||||
|
@ -28,7 +29,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
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 boolean emptyGrid;
|
||||
|
||||
/** Creates new form DraftGrid */
|
||||
/**
|
||||
* Creates new form DraftGrid
|
||||
*/
|
||||
public DraftGrid() {
|
||||
initComponents();
|
||||
markedCard = null;
|
||||
emptyGrid= true;
|
||||
emptyGrid = true;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
markedCard = null;
|
||||
this.clearCardEventListeners();
|
||||
for (Component comp: getComponents()) {
|
||||
for (Component comp : getComponents()) {
|
||||
if (comp instanceof Card || comp instanceof MageCard) {
|
||||
this.remove(comp);
|
||||
}
|
||||
|
@ -79,10 +81,10 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
|||
|
||||
CardDimensions cardDimension = null;
|
||||
int maxCards;
|
||||
double scale ;
|
||||
double scale;
|
||||
|
||||
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);
|
||||
maxCards = this.getWidth() / (cardDimension.getFrameWidth() + offsetX);
|
||||
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());
|
||||
sortedCards.sort(new CardViewRarityComparator());
|
||||
for (CardView card: sortedCards) {
|
||||
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, dimension, null, true, true);
|
||||
for (CardView card : sortedCards) {
|
||||
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, dimension, null, true, true, PreferencesDialog.getRenderMode());
|
||||
cardImg.addMouseListener(this);
|
||||
add(cardImg);
|
||||
cardImg.update(card);
|
||||
|
@ -133,7 +135,8 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
|||
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.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* 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);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 300, Short.MAX_VALUE)
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 300, Short.MAX_VALUE)
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
@ -160,7 +163,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
|||
if (e.getButton() == MouseEvent.BUTTON1) {
|
||||
Object obj = e.getSource();
|
||||
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();
|
||||
AudioManager.playOnDraftSelect();
|
||||
}
|
||||
|
@ -177,8 +180,8 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
|||
if (this.markedCard != null) {
|
||||
markedCard.setSelected(false);
|
||||
}
|
||||
this.cardEventSource.fireEvent(((MageCard)obj).getOriginal(), ClientEventType.MARK_A_CARD);
|
||||
markedCard = ((MageCard)obj);
|
||||
this.cardEventSource.fireEvent(((MageCard) obj).getOriginal(), ClientEventType.MARK_A_CARD);
|
||||
markedCard = ((MageCard) obj);
|
||||
markedCard.setSelected(true);
|
||||
repaint();
|
||||
}
|
||||
|
|
|
@ -1,16 +1,5 @@
|
|||
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.MageCard;
|
||||
import mage.cards.decks.DeckCardInfo;
|
||||
|
@ -31,6 +20,18 @@ import mage.view.CardsView;
|
|||
import org.apache.log4j.Logger;
|
||||
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.
|
||||
*/
|
||||
|
@ -456,6 +457,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
--count;
|
||||
}
|
||||
}
|
||||
|
||||
private int count = 0;
|
||||
}
|
||||
|
||||
|
@ -511,14 +513,14 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
};
|
||||
|
||||
private final CardTypeCounter[] allCounters = {
|
||||
creatureCounter,
|
||||
landCounter,
|
||||
artifactCounter,
|
||||
enchantmentCounter,
|
||||
instantCounter,
|
||||
planeswalkerCounter,
|
||||
sorceryCounter,
|
||||
tribalCounter
|
||||
creatureCounter,
|
||||
landCounter,
|
||||
artifactCounter,
|
||||
enchantmentCounter,
|
||||
instantCounter,
|
||||
planeswalkerCounter,
|
||||
sorceryCounter,
|
||||
tribalCounter
|
||||
};
|
||||
|
||||
// Listener
|
||||
|
@ -659,7 +661,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
|
||||
@Override
|
||||
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();
|
||||
|
||||
// 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.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.DlgParams;
|
||||
import mage.client.components.ext.dlg.IDialogPanel;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.Command;
|
||||
import mage.client.util.SettingsManager;
|
||||
|
@ -162,7 +163,7 @@ public class ChoiceDialog extends IDialogPanel {
|
|||
}
|
||||
|
||||
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));
|
||||
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.DlgParams;
|
||||
import mage.client.components.ext.dlg.IDialogPanel;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.game.FeedbackPanel;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.Command;
|
||||
|
@ -33,14 +34,14 @@ public class StackDialog extends IDialogPanel {
|
|||
|
||||
private JLayeredPane jLayeredPane;
|
||||
private final FeedbackPanel feedbackPanel;
|
||||
|
||||
|
||||
private final UUID gameId;
|
||||
|
||||
private static class CustomLabel extends JLabel {
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
Graphics2D g2D = (Graphics2D)g;
|
||||
Graphics2D g2D = (Graphics2D) g;
|
||||
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
|
@ -66,7 +67,7 @@ public class StackDialog extends IDialogPanel {
|
|||
|
||||
/**
|
||||
* This method initializes this
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private void initialize() {
|
||||
|
@ -111,7 +112,7 @@ public class StackDialog extends IDialogPanel {
|
|||
for (CardView card : cards.values()) {
|
||||
|
||||
if (card instanceof StackAbilityView) {
|
||||
CardView tmp = ((StackAbilityView)card).getSourceCard();
|
||||
CardView tmp = ((StackAbilityView) card).getSourceCard();
|
||||
tmp.overrideRules(card.getRules());
|
||||
tmp.setIsAbility(true);
|
||||
tmp.overrideTargets(card.getTargets());
|
||||
|
@ -119,7 +120,7 @@ public class StackDialog extends IDialogPanel {
|
|||
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.setLocation(dx, dy);
|
||||
|
||||
|
@ -143,10 +144,11 @@ public class StackDialog extends IDialogPanel {
|
|||
jButtonAccept.setObserver(new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
DialogManager.getManager(gameId).fadeOut((DialogContainer)getParent());
|
||||
DialogManager.getManager(gameId).fadeOut((DialogContainer) getParent());
|
||||
//GameManager.getInputControl().getInput().selectButtonOK();
|
||||
StackDialog.this.feedbackPanel.doClick();
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
});
|
||||
}
|
||||
|
@ -166,11 +168,12 @@ public class StackDialog extends IDialogPanel {
|
|||
jButtonResponse.setObserver(new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
DialogManager.getManager(gameId).fadeOut((DialogContainer)getParent());
|
||||
DialogManager.getManager(gameId).fadeOut((DialogContainer) getParent());
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
});
|
||||
}
|
||||
return jButtonResponse;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import mage.cards.repository.ExpansionRepository;
|
|||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.components.HoverButton;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.ImageHelper;
|
||||
|
@ -406,7 +407,7 @@ public class MageBook extends JComponent {
|
|||
if (cardDimension == null) {
|
||||
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);
|
||||
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
|
||||
cardImg.update(card);
|
||||
|
@ -447,7 +448,7 @@ public class MageBook extends JComponent {
|
|||
newToken.removeSummoningSickness();
|
||||
PermanentView theToken = new PermanentView(newToken, null, null, null);
|
||||
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);
|
||||
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
|
||||
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) {
|
||||
switch (key) {
|
||||
default:
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
|
@ -30,9 +26,17 @@
|
|||
<EmptySpace min="0" pref="578" max="32767" attributes="0"/>
|
||||
<Component id="buttonCancel" min="-2" pref="100" max="-2" attributes="0"/>
|
||||
</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">
|
||||
<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"/>
|
||||
</Group>
|
||||
</Group>
|
||||
|
@ -44,9 +48,17 @@
|
|||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="88" max="32767" attributes="0"/>
|
||||
<Component id="cardArea1" min="-2" pref="327" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Group type="103" groupAlignment="3" 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"/>
|
||||
<Component id="buttonCancel" min="-2" pref="30" 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"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="mage.client.cards.CardArea" name="cardArea1">
|
||||
<Component class="mage.client.cards.CardArea" name="cardsPanel">
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Component class="javax.swing.JButton" name="buttonReloadCards">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jButton1"/>
|
||||
<Property name="text" type="java.lang.String" value="Reload cards"/>
|
||||
</Properties>
|
||||
<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>
|
||||
</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>
|
||||
</Form>
|
||||
|
|
|
@ -11,6 +11,7 @@ import mage.cards.repository.ExpansionInfo;
|
|||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
import mage.constants.MultiplayerAttackOption;
|
||||
import mage.constants.RangeOfInfluence;
|
||||
import mage.game.Game;
|
||||
|
@ -26,6 +27,7 @@ import mage.view.PermanentView;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -35,6 +37,7 @@ import java.util.UUID;
|
|||
public class TestCardRenderDialog extends MageDialog {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(TestCardRenderDialog.class);
|
||||
float cardSizeMod = 1.0f;
|
||||
|
||||
public TestCardRenderDialog() {
|
||||
initComponents();
|
||||
|
@ -43,6 +46,7 @@ public class TestCardRenderDialog extends MageDialog {
|
|||
public void showDialog() {
|
||||
this.setModal(false);
|
||||
getRootPane().setDefaultButton(buttonCancel);
|
||||
reloadCards();
|
||||
|
||||
// windows settings
|
||||
MageFrame.getDesktop().remove(this);
|
||||
|
@ -74,77 +78,17 @@ public class TestCardRenderDialog extends MageDialog {
|
|||
if (damage > 0) {
|
||||
perm.damage(damage, null, game);
|
||||
}
|
||||
perm.removeSummoningSickness();
|
||||
PermanentView cardView = new PermanentView(perm, card, controllerId, game);
|
||||
cardView.setInViewerOnly(true);
|
||||
|
||||
return cardView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
private void reloadCards() {
|
||||
cardsPanel.cleanUp();
|
||||
cardsPanel.setCustomRenderMode(comboRenderMode.getSelectedIndex());
|
||||
|
||||
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);
|
||||
Player player = new StubPlayer("player1", RangeOfInfluence.ALL);
|
||||
Deck deck = new Deck();
|
||||
|
@ -160,13 +104,147 @@ public class TestCardRenderDialog extends MageDialog {
|
|||
card = createCard(game, player.getId(), "RNA", "14", 1); // Knight of Sorrows
|
||||
view.put(card.getId(), card);
|
||||
|
||||
cardArea1.loadCards(view, big, null);
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
cardsPanel.setCustomCardSize(new Dimension(getCardWidth(), getCardHeight()));
|
||||
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
|
||||
private javax.swing.JButton buttonCancel;
|
||||
private mage.client.cards.CardArea cardArea1;
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JButton buttonReloadCards;
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -1,254 +1,245 @@
|
|||
|
||||
|
||||
/*
|
||||
* BattlefieldPanel.java
|
||||
*
|
||||
* Created on 10-Jan-2010, 10:43:14 PM
|
||||
*/
|
||||
package mage.client.game;
|
||||
* BattlefieldPanel.java
|
||||
*
|
||||
* Created on 10-Jan-2010, 10:43:14 PM
|
||||
*/
|
||||
package mage.client.game;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
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 mage.cards.MagePermanent;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.cards.Permanent;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
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;
|
||||
private BigCard bigCard;
|
||||
private final Map<String, JComponent> uiComponentsList = new HashMap<>();
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
||||
|
||||
protected Map<UUID, PermanentView> battlefield;
|
||||
private Dimension cardDimension;
|
||||
private final Map<UUID, MagePermanent> permanents = new LinkedHashMap<>();
|
||||
private UUID gameId;
|
||||
private BigCard bigCard;
|
||||
private final Map<String, JComponent> uiComponentsList = new HashMap<>();
|
||||
|
||||
private JLayeredPane jPanel;
|
||||
private JScrollPane jScrollPane;
|
||||
private int width;
|
||||
protected Map<UUID, PermanentView> battlefield;
|
||||
private Dimension cardDimension;
|
||||
|
||||
private final CardLayoutStrategy layoutStrategy = new OldCardLayoutStrategy();
|
||||
private JLayeredPane jPanel;
|
||||
private JScrollPane jScrollPane;
|
||||
private int width;
|
||||
|
||||
//private static int iCounter = 0;
|
||||
private boolean addedPermanent;
|
||||
private boolean addedArtifact;
|
||||
private boolean addedCreature;
|
||||
private final CardLayoutStrategy layoutStrategy = new OldCardLayoutStrategy();
|
||||
|
||||
private boolean removedCreature;
|
||||
// defines if the battlefield is within a top (means top row of player panels) or a bottom player panel
|
||||
private boolean topPanelBattlefield;
|
||||
//private static int iCounter = 0;
|
||||
private boolean addedPermanent;
|
||||
private boolean addedArtifact;
|
||||
private boolean addedCreature;
|
||||
|
||||
/**
|
||||
* Creates new form BattlefieldPanel
|
||||
*/
|
||||
public BattlefieldPanel() {
|
||||
uiComponentsList.put("battlefieldPanel", this);
|
||||
initComponents();
|
||||
uiComponentsList.put("jPanel", jPanel);
|
||||
setGUISize();
|
||||
private boolean removedCreature;
|
||||
// defines if the battlefield is within a top (means top row of player panels) or a bottom player panel
|
||||
private boolean topPanelBattlefield;
|
||||
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Creates new form BattlefieldPanel
|
||||
*/
|
||||
public BattlefieldPanel() {
|
||||
uiComponentsList.put("battlefieldPanel", this);
|
||||
initComponents();
|
||||
uiComponentsList.put("jPanel", jPanel);
|
||||
setGUISize();
|
||||
|
||||
public void init(UUID gameId, BigCard bigCard) {
|
||||
this.gameId = gameId;
|
||||
this.bigCard = bigCard;
|
||||
}
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
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() {
|
||||
for (Component c : this.jPanel.getComponents()) {
|
||||
if (c instanceof Permanent || c instanceof MagePermanent) {
|
||||
this.jPanel.remove(c);
|
||||
}
|
||||
}
|
||||
permanents.clear();
|
||||
// Plugins.getInstance().sortPermanents(uiComponentsList, permanents.values());
|
||||
this.bigCard = null;
|
||||
}
|
||||
public void init(UUID gameId, BigCard bigCard) {
|
||||
this.gameId = gameId;
|
||||
this.bigCard = bigCard;
|
||||
}
|
||||
|
||||
public void changeGUISize() {
|
||||
setGUISize();
|
||||
sortLayout();
|
||||
}
|
||||
public void cleanUp() {
|
||||
for (Component c : this.jPanel.getComponents()) {
|
||||
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() {
|
||||
jScrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0));
|
||||
jScrollPane.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GUISizeHelper.scrollBarSize));
|
||||
cardDimension = GUISizeHelper.battlefieldCardMaxDimension;
|
||||
}
|
||||
public void changeGUISize() {
|
||||
setGUISize();
|
||||
sortLayout();
|
||||
}
|
||||
|
||||
public boolean isTopPanelBattlefield() {
|
||||
return topPanelBattlefield;
|
||||
}
|
||||
private void setGUISize() {
|
||||
jScrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0));
|
||||
jScrollPane.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GUISizeHelper.scrollBarSize));
|
||||
cardDimension = GUISizeHelper.battlefieldCardMaxDimension;
|
||||
}
|
||||
|
||||
public void setTopPanelBattlefield(boolean topPanelBattlefield) {
|
||||
this.topPanelBattlefield = topPanelBattlefield;
|
||||
}
|
||||
public boolean isTopPanelBattlefield() {
|
||||
return topPanelBattlefield;
|
||||
}
|
||||
|
||||
public void update(Map<UUID, PermanentView> battlefield) {
|
||||
boolean changed = false;
|
||||
public void setTopPanelBattlefield(boolean topPanelBattlefield) {
|
||||
this.topPanelBattlefield = topPanelBattlefield;
|
||||
}
|
||||
|
||||
List<PermanentView> permanentsToAdd = new ArrayList<>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
public void update(Map<UUID, PermanentView> battlefield) {
|
||||
boolean changed = false;
|
||||
|
||||
}
|
||||
oldMagePermanent.update(permanent);
|
||||
}
|
||||
}
|
||||
List<PermanentView> permanentsToAdd = new ArrayList<>();
|
||||
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();
|
||||
for (PermanentView permanent : permanentsToAdd) {
|
||||
addPermanent(permanent, count);
|
||||
}
|
||||
addedArtifact = addedCreature = addedPermanent = false;
|
||||
|
||||
if (addedArtifact) {
|
||||
AudioManager.playAddArtifact();
|
||||
} else if (addedCreature) {
|
||||
AudioManager.playSummon();
|
||||
} else if (addedPermanent) {
|
||||
AudioManager.playAddPermanent();
|
||||
}
|
||||
int count = permanentsToAdd.size();
|
||||
for (PermanentView permanent : permanentsToAdd) {
|
||||
addPermanent(permanent, count);
|
||||
}
|
||||
|
||||
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();) {
|
||||
Entry<UUID, MagePermanent> entry = iterator.next();
|
||||
if (!battlefield.containsKey(entry.getKey()) || !battlefield.get(entry.getKey()).isPhasedIn()) {
|
||||
removePermanent(entry.getKey(), 1);
|
||||
iterator.remove();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
removedCreature = false;
|
||||
|
||||
if (removedCreature) {
|
||||
AudioManager.playDiedCreature();
|
||||
}
|
||||
for (Iterator<Entry<UUID, MagePermanent>> iterator = permanents.entrySet().iterator(); iterator.hasNext(); ) {
|
||||
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) {
|
||||
this.battlefield = battlefield;
|
||||
sortLayout();
|
||||
}
|
||||
}
|
||||
if (removedCreature) {
|
||||
AudioManager.playDiedCreature();
|
||||
}
|
||||
|
||||
public void sortLayout() {
|
||||
if (battlefield == null || this.getWidth() < 1) { // Can't do layout when panel is not sized yet
|
||||
return;
|
||||
}
|
||||
if (changed) {
|
||||
this.battlefield = battlefield;
|
||||
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();
|
||||
this.jScrollPane.revalidate();
|
||||
layoutStrategy.doLayout(this, width);
|
||||
|
||||
invalidate();
|
||||
repaint();
|
||||
}
|
||||
this.jScrollPane.repaint();
|
||||
this.jScrollPane.revalidate();
|
||||
|
||||
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);
|
||||
invalidate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
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);
|
||||
//this.jPanel.add(perm);
|
||||
if (!Plugins.instance.isCardPluginLoaded()) {
|
||||
moveToFront(perm);
|
||||
perm.update(permanent);
|
||||
} else {
|
||||
moveToFront(jPanel);
|
||||
Plugins.instance.onAddCard(perm, 1);
|
||||
permanents.put(permanent.getId(), perm);
|
||||
|
||||
BattlefieldPanel.this.jPanel.add(perm, 10);
|
||||
//this.jPanel.add(perm);
|
||||
if (!Plugins.instance.isCardPluginLoaded()) {
|
||||
moveToFront(perm);
|
||||
perm.update(permanent);
|
||||
} else {
|
||||
moveToFront(jPanel);
|
||||
Plugins.instance.onAddCard(perm, 1);
|
||||
/*Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -258,76 +249,76 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
synchronized (this) {
|
||||
threads.add(t);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
if (permanent.isArtifact()) {
|
||||
addedArtifact = true;
|
||||
} else if (permanent.isCreature()) {
|
||||
addedCreature = true;
|
||||
} else {
|
||||
addedPermanent = true;
|
||||
}
|
||||
}
|
||||
if (permanent.isArtifact()) {
|
||||
addedArtifact = true;
|
||||
} else if (permanent.isCreature()) {
|
||||
addedCreature = true;
|
||||
} else {
|
||||
addedPermanent = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void removePermanent(UUID permanentId, final int count) {
|
||||
for (Component c : this.jPanel.getComponents()) {
|
||||
final Component comp = c;
|
||||
if (comp instanceof Permanent) {
|
||||
if (((Permanent) comp).getPermanentId().equals(permanentId)) {
|
||||
comp.setVisible(false);
|
||||
this.jPanel.remove(comp);
|
||||
}
|
||||
} else if (comp instanceof MagePermanent) {
|
||||
if (((MagePermanent) comp).getOriginal().getId().equals(permanentId)) {
|
||||
Thread t = new Thread(() -> {
|
||||
Plugins.instance.onRemoveCard((MagePermanent) comp, count);
|
||||
comp.setVisible(false);
|
||||
BattlefieldPanel.this.jPanel.remove(comp);
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
if (((MagePermanent) comp).getOriginal().isCreature()) {
|
||||
removedCreature = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void removePermanent(UUID permanentId, final int count) {
|
||||
for (Component c : this.jPanel.getComponents()) {
|
||||
final Component comp = c;
|
||||
if (comp instanceof Permanent) {
|
||||
if (((Permanent) comp).getPermanentId().equals(permanentId)) {
|
||||
comp.setVisible(false);
|
||||
this.jPanel.remove(comp);
|
||||
}
|
||||
} else if (comp instanceof MagePermanent) {
|
||||
if (((MagePermanent) comp).getOriginal().getId().equals(permanentId)) {
|
||||
Thread t = new Thread(() -> {
|
||||
Plugins.instance.onRemoveCard((MagePermanent) comp, count);
|
||||
comp.setVisible(false);
|
||||
BattlefieldPanel.this.jPanel.remove(comp);
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
if (((MagePermanent) comp).getOriginal().isCreature()) {
|
||||
removedCreature = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOptimizedDrawingEnabled() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isOptimizedDrawingEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Map<UUID, MagePermanent> getPermanents() {
|
||||
return permanents;
|
||||
}
|
||||
public Map<UUID, MagePermanent> getPermanents() {
|
||||
return permanents;
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
setOpaque(false);
|
||||
private void initComponents() {
|
||||
setOpaque(false);
|
||||
|
||||
jPanel = new JLayeredPane();
|
||||
jPanel.setLayout(null);
|
||||
jPanel.setOpaque(false);
|
||||
jScrollPane = new JScrollPane(jPanel);
|
||||
jPanel = new JLayeredPane();
|
||||
jPanel.setLayout(null);
|
||||
jPanel.setOpaque(false);
|
||||
jScrollPane = new JScrollPane(jPanel);
|
||||
|
||||
Border empty = new EmptyBorder(0, 0, 0, 0);
|
||||
jScrollPane.setBorder(empty);
|
||||
jScrollPane.setViewportBorder(empty);
|
||||
jScrollPane.setOpaque(false);
|
||||
jScrollPane.getViewport().setOpaque(false);
|
||||
Border empty = new EmptyBorder(0, 0, 0, 0);
|
||||
jScrollPane.setBorder(empty);
|
||||
jScrollPane.setViewportBorder(empty);
|
||||
jScrollPane.setOpaque(false);
|
||||
jScrollPane.getViewport().setOpaque(false);
|
||||
|
||||
this.add(jScrollPane);
|
||||
}
|
||||
this.add(jScrollPane);
|
||||
}
|
||||
|
||||
public JLayeredPane getMainPanel() {
|
||||
return jPanel;
|
||||
}
|
||||
public JLayeredPane getMainPanel() {
|
||||
return jPanel;
|
||||
}
|
||||
|
||||
public Map<UUID, PermanentView> getBattlefield() {
|
||||
return battlefield;
|
||||
}
|
||||
public Map<UUID, PermanentView> getBattlefield() {
|
||||
return battlefield;
|
||||
}
|
||||
|
||||
public Map<String, JComponent> getUiComponentsList() {
|
||||
return uiComponentsList;
|
||||
}
|
||||
}
|
||||
public Map<String, JComponent> getUiComponentsList() {
|
||||
return uiComponentsList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
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.MagePermanent;
|
||||
import mage.cards.action.ActionCallback;
|
||||
|
@ -12,6 +7,12 @@ import mage.client.cards.BigCard;
|
|||
import mage.view.CardView;
|
||||
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 {
|
||||
|
||||
void loadPlugins();
|
||||
|
@ -22,9 +23,9 @@ public interface MagePlugins {
|
|||
|
||||
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();
|
||||
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
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.MagePermanent;
|
||||
import mage.cards.action.ActionCallback;
|
||||
|
@ -27,12 +20,20 @@ import mage.view.PermanentView;
|
|||
import net.xeoh.plugins.base.PluginManager;
|
||||
import net.xeoh.plugins.base.impl.PluginManagerFactory;
|
||||
import net.xeoh.plugins.base.util.uri.ClassURI;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.plugins.card.CardPluginImpl;
|
||||
import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
|
||||
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 {
|
||||
instance;
|
||||
public static final String PLUGINS_DIRECTORY = "plugins";
|
||||
|
@ -92,24 +93,24 @@ public enum Plugins implements MagePlugins {
|
|||
}
|
||||
|
||||
@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) {
|
||||
mageActionCallback.refreshSession();
|
||||
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 {
|
||||
return new Permanent(card, bigCard, Config.dimensions, gameId);
|
||||
}
|
||||
}
|
||||
|
||||
@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 (previewable) {
|
||||
mageActionCallback.refreshSession();
|
||||
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 {
|
||||
return new Card(card, bigCard, Config.dimensions, gameId);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.mage.plugins.card;
|
|||
|
||||
import mage.cards.MagePermanent;
|
||||
import mage.cards.action.ActionCallback;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
import mage.interfaces.plugin.CardPlugin;
|
||||
import mage.view.CardView;
|
||||
|
@ -99,25 +98,28 @@ public class CardPluginImpl implements CardPlugin {
|
|||
* Temporary card rendering shim. Split card rendering isn't implemented
|
||||
* 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) {
|
||||
String fallback = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_FALLBACK, "false");
|
||||
if (fallback.equals("true")) {
|
||||
return new CardPanelComponentImpl(view, gameId, loadImage, callback, isFoil, dimension);
|
||||
} else {
|
||||
return new CardPanelRenderImpl(view, gameId, loadImage, callback, isFoil, dimension);
|
||||
private CardPanel makePanel(CardView view, UUID gameId, boolean loadImage, ActionCallback callback, boolean isFoil, Dimension dimension, int renderMode) {
|
||||
switch (renderMode) {
|
||||
case 0:
|
||||
return new CardPanelRenderImpl(view, gameId, loadImage, callback, isFoil, dimension);
|
||||
case 1:
|
||||
return new CardPanelComponentImpl(view, gameId, loadImage, callback, isFoil, dimension);
|
||||
default:
|
||||
throw new IllegalStateException("Unknown render mode " + renderMode);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage) {
|
||||
CardPanel cardPanel = makePanel(permanent, gameId, loadImage, callback, false, dimension);
|
||||
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, renderMode);
|
||||
cardPanel.setShowCastingCost(true);
|
||||
return cardPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagePermanent getMageCard(CardView cardView, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage) {
|
||||
CardPanel cardPanel = makePanel(cardView, gameId, loadImage, callback, false, dimension);
|
||||
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, renderMode);
|
||||
cardPanel.setShowCastingCost(true);
|
||||
return cardPanel;
|
||||
}
|
||||
|
|
|
@ -1,30 +1,28 @@
|
|||
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.action.ActionCallback;
|
||||
import mage.view.CardView;
|
||||
import mage.view.PermanentView;
|
||||
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
|
||||
*
|
||||
* @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
|
||||
* @version 0.1 31.10.2010 #getMagePermanent, #sortPermanents
|
||||
*/
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue