mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
fixes
This commit is contained in:
parent
e61ad860b1
commit
d79cbcb54f
4 changed files with 27 additions and 19 deletions
|
|
@ -31,6 +31,7 @@ package mage.client.cards;
|
|||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.swing.JLayeredPane;
|
||||
|
|
@ -67,44 +68,44 @@ public class CardArea extends JPanel {
|
|||
|
||||
}
|
||||
|
||||
public void loadCards(SimpleCardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
||||
loadCards(CardsViewUtil.convertSimple(showCards), bigCard, dimension, gameId);
|
||||
public void loadCards(SimpleCardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, MouseListener listener) {
|
||||
loadCards(CardsViewUtil.convertSimple(showCards), bigCard, dimension, gameId, listener);
|
||||
}
|
||||
|
||||
public void loadCards(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
||||
public void loadCards(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, MouseListener listener) {
|
||||
this.reloaded = true;
|
||||
cardArea.removeAll();
|
||||
if (showCards != null && showCards.size() < 10)
|
||||
loadCardsFew(showCards, bigCard, gameId);
|
||||
loadCardsFew(showCards, bigCard, gameId, listener);
|
||||
else
|
||||
loadCardsMany(showCards, bigCard, gameId);
|
||||
loadCardsMany(showCards, bigCard, gameId, listener);
|
||||
cardArea.revalidate();
|
||||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
public void loadCardsNarrow(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
||||
public void loadCardsNarrow(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, MouseListener listener) {
|
||||
this.reloaded = true;
|
||||
cardArea.removeAll();
|
||||
loadCardsMany(showCards, bigCard, gameId);
|
||||
loadCardsMany(showCards, bigCard, gameId, listener);
|
||||
cardArea.revalidate();
|
||||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private void loadCardsFew(CardsView showCards, BigCard bigCard, UUID gameId) {
|
||||
private void loadCardsFew(CardsView showCards, BigCard bigCard, UUID gameId, MouseListener listener) {
|
||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
Dimension dimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
for (CardView card : showCards.values()) {
|
||||
addCard(card, bigCard, gameId, rectangle, dimension);
|
||||
addCard(card, bigCard, gameId, rectangle, dimension, listener);
|
||||
rectangle.translate(Config.dimensions.frameWidth, 0);
|
||||
}
|
||||
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth * showCards.size(), Config.dimensions.frameHeight));
|
||||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle, Dimension dimension) {
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle, Dimension dimension, MouseListener listener) {
|
||||
if (card instanceof AbilityView) {
|
||||
CardView tmp = ((AbilityView) card).getSourceCard();
|
||||
tmp.overrideRules(card.getRules());
|
||||
|
|
@ -115,20 +116,22 @@ public class CardArea extends JPanel {
|
|||
}
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, dimension, gameId, true);
|
||||
cardImg.setBounds(rectangle);
|
||||
if (listener != null)
|
||||
cardImg.addMouseListener(listener);
|
||||
cardArea.add(cardImg);
|
||||
cardArea.moveToFront(cardImg);
|
||||
cardImg.update(card);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
|
||||
private void loadCardsMany(CardsView showCards, BigCard bigCard, UUID gameId) {
|
||||
private void loadCardsMany(CardsView showCards, BigCard bigCard, UUID gameId, MouseListener listener) {
|
||||
int columns = 1;
|
||||
if (showCards != null && showCards.size() > 0) {
|
||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
Dimension dimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
int count = 0;
|
||||
for (CardView card : showCards.values()) {
|
||||
addCard(card, bigCard, gameId, rectangle, dimension);
|
||||
addCard(card, bigCard, gameId, rectangle, dimension, listener);
|
||||
if (count >= 20) {
|
||||
rectangle.translate(Config.dimensions.frameWidth, -400);
|
||||
columns++;
|
||||
|
|
|
|||
|
|
@ -98,8 +98,8 @@ public class PickPileDialog extends MageDialog {
|
|||
|
||||
public void loadCards(String name, CardsView pile1, CardsView pile2, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
||||
this.title = name;
|
||||
this.pile1.loadCardsNarrow(pile1, bigCard, dimension, gameId);
|
||||
this.pile2.loadCardsNarrow(pile2, bigCard, dimension, gameId);
|
||||
this.pile1.loadCardsNarrow(pile1, bigCard, dimension, gameId, null);
|
||||
this.pile2.loadCardsNarrow(pile2, bigCard, dimension, gameId, null);
|
||||
|
||||
if (getParent() != MageFrame.getDesktop() /*|| this.isClosed*/) {
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.POPUP_LAYER);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
|||
public void loadCards(String name, CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean modal) {
|
||||
this.reloaded = true;
|
||||
this.title = name;
|
||||
cardArea.loadCards(showCards, bigCard, dimension, gameId);
|
||||
cardArea.loadCards(showCards, bigCard, dimension, gameId, this);
|
||||
if (getParent() != MageFrame.getDesktop() /*|| this.isClosed*/) {
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.POPUP_LAYER);
|
||||
}
|
||||
|
|
@ -115,6 +115,7 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
|||
setResizable(true);
|
||||
getContentPane().setLayout(new java.awt.BorderLayout());
|
||||
getContentPane().add(cardArea, java.awt.BorderLayout.CENTER);
|
||||
this.addMouseListener(this);
|
||||
|
||||
pack();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue