mirror of
https://github.com/correl/mage.git
synced 2024-11-22 03:00:11 +00:00
Reduced hand cards size. Removed battlefield card area gap (cards now have more place and are less reduced in size).
This commit is contained in:
parent
93878d4868
commit
2abc0e888d
15 changed files with 81 additions and 36 deletions
Binary file not shown.
|
@ -208,6 +208,9 @@ public class BigCard extends JComponent {
|
|||
if (source == null) {
|
||||
source = BufferedImageBuilder.bufferImage(bigImage);
|
||||
}
|
||||
if (source == null) {
|
||||
return;
|
||||
}
|
||||
f = filter.filter(source, null);
|
||||
}
|
||||
synchronized (BigCard.class) {
|
||||
|
|
|
@ -67,6 +67,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener
|
|||
protected BigCard bigCard;
|
||||
protected UUID gameId;
|
||||
private Map<UUID, MageCard> cards = new HashMap<UUID, MageCard>();
|
||||
private Dimension cardDimension;
|
||||
|
||||
public CardGrid() {
|
||||
initComponents();
|
||||
|
@ -93,7 +94,10 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener
|
|||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, Config.dimensions, gameId, true);
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, true);
|
||||
cards.put(card.getId(), cardImg);
|
||||
cardImg.addMouseListener(this);
|
||||
add(cardImg);
|
||||
|
|
|
@ -65,6 +65,8 @@ public class Cards extends javax.swing.JPanel {
|
|||
private boolean dontDisplayTapped = false;
|
||||
private static final int GAP_X = 5;
|
||||
|
||||
private Dimension cardDimension;
|
||||
|
||||
/** Creates new form Cards */
|
||||
public Cards() {
|
||||
this(false);
|
||||
|
@ -125,7 +127,7 @@ public class Cards extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
if (changed) {
|
||||
layoutCards(Config.dimensions);
|
||||
layoutCards(getCardDimension());
|
||||
}
|
||||
|
||||
cardArea.setPreferredSize(new Dimension(cards.size() * (Config.dimensions.frameWidth + GAP_X), Config.dimensions.frameHeight));
|
||||
|
@ -137,8 +139,15 @@ public class Cards extends javax.swing.JPanel {
|
|||
return changed;
|
||||
}
|
||||
|
||||
private Dimension getCardDimension() {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
return cardDimension;
|
||||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, Config.dimensions, gameId, true);
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, getCardDimension(), gameId, true);
|
||||
cards.put(card.getId(), cardImg);
|
||||
cardArea.add(cardImg);
|
||||
}
|
||||
|
@ -157,13 +166,13 @@ public class Cards extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
private void layoutCards(CardDimensions dimension) {
|
||||
private void layoutCards(Dimension dimension) {
|
||||
if (Plugins.getInstance().isCardPluginLoaded()) {
|
||||
int dx = 0;
|
||||
for (MageCard card: cards.values()) {
|
||||
card.setLocation(dx, 0);
|
||||
card.setCardBounds(dx, 0, dimension.frameWidth, dimension.frameHeight);
|
||||
dx += dimension.frameWidth + GAP_X;
|
||||
card.setCardBounds(dx, 0, dimension.width, dimension.height);
|
||||
dx += dimension.width + GAP_X;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -213,4 +222,8 @@ public class Cards extends javax.swing.JPanel {
|
|||
jScrollPane1.getVerticalScrollBar().setUnitIncrement(unitIncrement);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCardDimension(Dimension dimension) {
|
||||
this.cardDimension = dimension;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ import mage.view.CardsView;
|
|||
public class CardsList extends javax.swing.JPanel implements MouseListener {
|
||||
|
||||
protected CardEventSource cardEventSource = new CardEventSource();
|
||||
private Dimension cardDimension;
|
||||
|
||||
/** Creates new form Cards */
|
||||
public CardsList() {
|
||||
|
@ -101,7 +102,10 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
|
|||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, Config.dimensions, gameId, true);
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, true);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardArea.add(cardImg);
|
||||
cardArea.moveToFront(cardImg);
|
||||
|
|
|
@ -11,10 +11,12 @@
|
|||
|
||||
package mage.client.cards;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.cards.CardDimensions;
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
|
@ -45,8 +47,9 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
|||
int curColumn = 0;
|
||||
int curRow = 0;
|
||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
Dimension dimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
for (CardView card: booster.values()) {
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, Config.dimensions, null, false);
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, dimension, null, false);
|
||||
cardImg.addMouseListener(this);
|
||||
add(cardImg);
|
||||
cardImg.update(card);
|
||||
|
|
|
@ -39,6 +39,7 @@ import mage.client.components.arcane.ManaSymbols;
|
|||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.AudioManager;
|
||||
import mage.client.util.Command;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.ImageHelper;
|
||||
import mage.components.ImagePanel;
|
||||
import mage.view.CardView;
|
||||
|
@ -212,7 +213,10 @@ public class MageBook extends JComponent {
|
|||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
|
||||
final MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimensions, gameId, false);
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
final MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, false);
|
||||
cardImg.setBounds(rectangle);
|
||||
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
|
||||
cardImg.update(card);
|
||||
|
@ -296,6 +300,7 @@ public class MageBook extends JComponent {
|
|||
private static CardDimensions cardDimensions = new CardDimensions(1.2d);
|
||||
private static Font font = new Font("Arial", Font.PLAIN, 14);
|
||||
private static final Logger log = Logger.getLogger(MageBook.class);
|
||||
private Dimension cardDimension;
|
||||
|
||||
static private final String CENTER_PANEL_IMAGE_PATH = "/book_bg.jpg";
|
||||
static private final String RIGHT_PANEL_IMAGE_PATH = "/book_right.jpg";
|
||||
|
|
|
@ -71,9 +71,9 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
|||
this.title = name;
|
||||
cardArea.removeAll();
|
||||
if (showCards != null && showCards.size() < 10)
|
||||
loadCardsFew(showCards, bigCard, dimension, gameId);
|
||||
loadCardsFew(showCards, bigCard, gameId);
|
||||
else
|
||||
loadCardsMany(showCards, bigCard, dimension, gameId);
|
||||
loadCardsMany(showCards, bigCard, gameId);
|
||||
cardArea.revalidate();
|
||||
if (getParent() != MageFrame.getDesktop() /*|| this.isClosed*/) {
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.POPUP_LAYER);
|
||||
|
@ -85,8 +85,9 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
|||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private void loadCardsFew(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
||||
private void loadCardsFew(CardsView showCards, BigCard bigCard, UUID gameId) {
|
||||
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);
|
||||
rectangle.translate(Config.dimensions.frameWidth, 0);
|
||||
|
@ -94,7 +95,7 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
|||
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth * showCards.size(), Config.dimensions.frameHeight));
|
||||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle, CardDimensions dimension) {
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle, Dimension dimension) {
|
||||
if (card instanceof AbilityView) {
|
||||
CardView tmp = ((AbilityView)card).getSourceCard();
|
||||
tmp.overrideRules(card.getRules());
|
||||
|
@ -112,10 +113,11 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
|||
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
|
||||
private void loadCardsMany(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
||||
private void loadCardsMany(CardsView showCards, BigCard bigCard, UUID gameId) {
|
||||
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);
|
||||
|
|
|
@ -73,6 +73,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
|
||||
protected static Map<UUID, PermanentView> battlefield;
|
||||
protected static List<Thread> threads = new ArrayList<Thread>();
|
||||
private static Dimension cardDimension;
|
||||
|
||||
/** Creates new form BattlefieldPanel */
|
||||
public BattlefieldPanel(JScrollPane jScrollPane) {
|
||||
|
@ -154,7 +155,10 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
}
|
||||
|
||||
private void addPermanent(PermanentView permanent, final int count) {
|
||||
final MagePermanent perm = Plugins.getInstance().getMagePermanent(permanent, bigCard, Config.dimensions, gameId, true);
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
final MagePermanent perm = Plugins.getInstance().getMagePermanent(permanent, bigCard, cardDimension, gameId, true);
|
||||
if (!Plugins.getInstance().isCardPluginLoaded()) {
|
||||
perm.setBounds(findEmptySpace(new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight)));
|
||||
} else {
|
||||
|
|
|
@ -88,6 +88,8 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
private UUID playerId;
|
||||
private Session session;
|
||||
|
||||
private static final Dimension handCardDimension = new Dimension(75, (int)(75 * 3.5f / 2.5f));
|
||||
|
||||
/** Creates new form GamePanel */
|
||||
public GamePanel() {
|
||||
initComponents();
|
||||
|
@ -289,7 +291,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
} else {
|
||||
this.hand.loadCards(game.getHand(), bigCard, gameId);
|
||||
int count = game.getHand().size();
|
||||
hand.setPreferredSize(new java.awt.Dimension((Config.dimensions.frameWidth + 5) * count + 5, Config.dimensions.frameHeight + 20)); // for scroll
|
||||
hand.setPreferredSize(new java.awt.Dimension((handCardDimension.width + 5) * count + 5, handCardDimension.height + 20)); // for scroll
|
||||
}
|
||||
if (game.getPhase() != null)
|
||||
this.txtPhase.setText(game.getPhase().toString());
|
||||
|
@ -381,9 +383,9 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
return JOptionPane.showConfirmDialog(this, message, title, JOptionPane.YES_NO_OPTION);
|
||||
}
|
||||
|
||||
public JPanel getHand() {
|
||||
/*public JPanel getHand() {
|
||||
return hand;
|
||||
}
|
||||
}*/
|
||||
|
||||
public void select(String message, GameView gameView) {
|
||||
updateGame(gameView);
|
||||
|
@ -439,9 +441,9 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
return players;
|
||||
}
|
||||
|
||||
public javax.swing.JPanel getBattlefield() {
|
||||
/*public javax.swing.JPanel getBattlefield() {
|
||||
return pnlBattlefield;
|
||||
}
|
||||
}*/
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -480,6 +482,8 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
hand = new mage.client.cards.Cards(true);
|
||||
chatPanel = new mage.client.chat.ChatPanel();
|
||||
|
||||
hand.setCardDimension(handCardDimension);
|
||||
|
||||
jSplitPane1.setBorder(null);
|
||||
jSplitPane1.setDividerSize(7);
|
||||
jSplitPane1.setResizeWeight(1.0);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package mage.client.plugins;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -21,8 +21,8 @@ public interface MagePlugins {
|
|||
void shutdown();
|
||||
void updateGamePanel(Map<String, JComponent> ui);
|
||||
JComponent updateTablePanel(Map<String, JComponent> ui);
|
||||
MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean canBeFoil);
|
||||
MageCard getMageCard(CardView card, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean canBeFoil);
|
||||
MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean canBeFoil);
|
||||
MageCard getMageCard(CardView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean canBeFoil);
|
||||
boolean isThemePluginLoaded();
|
||||
boolean isCardPluginLoaded();
|
||||
boolean isCounterPluginLoaded();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package mage.client.plugins.impl;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
@ -80,7 +80,7 @@ public class Plugins implements MagePlugins {
|
|||
}
|
||||
|
||||
@Override
|
||||
public MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean canBeFoil) {
|
||||
public MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean canBeFoil) {
|
||||
if (cardPlugin != null) {
|
||||
mageActionCallback.refreshSession();
|
||||
mageActionCallback.setCardPreviewComponent(bigCard);
|
||||
|
@ -91,7 +91,7 @@ public class Plugins implements MagePlugins {
|
|||
}
|
||||
|
||||
@Override
|
||||
public MageCard getMageCard(CardView card, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean canBeFoil) {
|
||||
public MageCard getMageCard(CardView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean canBeFoil) {
|
||||
if (cardPlugin != null) {
|
||||
mageActionCallback.refreshSession();
|
||||
mageActionCallback.setCardPreviewComponent(bigCard);
|
||||
|
|
|
@ -25,6 +25,9 @@ public class BufferedImageBuilder {
|
|||
}
|
||||
|
||||
public static BufferedImage bufferImage(Image image, int type) {
|
||||
if (image == null) {
|
||||
return null;
|
||||
}
|
||||
BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
|
||||
Graphics2D g = bufferedImage.createGraphics();
|
||||
g.drawImage(image, null, null);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package mage.interfaces.plugin;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -25,8 +25,8 @@ import net.xeoh.plugins.base.Plugin;
|
|||
* @author nantuko
|
||||
*/
|
||||
public interface CardPlugin extends Plugin {
|
||||
MagePermanent getMagePermanent(PermanentView permanent, CardDimensions dimension, UUID gameId, ActionCallback callback, boolean canBeFoil);
|
||||
MagePermanent getMageCard(CardView permanent, CardDimensions dimension, UUID gameId, ActionCallback callback, boolean canBeFoil);
|
||||
MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil);
|
||||
MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil);
|
||||
void sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> cards);
|
||||
void downloadImages(Set<Card> allCards);
|
||||
void downloadSymbols();
|
||||
|
|
|
@ -50,7 +50,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
static private final float CARD_SPACING_Y = 0.03f;
|
||||
static private final float STACK_SPACING_X = 0.07f;
|
||||
static private final float STACK_SPACING_Y = 0.13f;
|
||||
static private final int MW_GUIDE_HEIGHT = 30;
|
||||
//static private final int MW_GUIDE_HEIGHT = 30;
|
||||
|
||||
private int landStackMax = 5;
|
||||
private int cardWidthMin = 50, cardWidthMax = Constants.CARD_SIZE_FULL.width;
|
||||
|
@ -77,20 +77,20 @@ public class CardPluginImpl implements CardPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public MagePermanent getMagePermanent(PermanentView permanent, CardDimensions dimension, UUID gameId, ActionCallback callback, boolean canBeFoil) {
|
||||
public MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil) {
|
||||
boolean foil = canBeFoil && (new Random()).nextInt(5) == 0;
|
||||
CardPanel cardPanel = new CardPanel(permanent, gameId, true, callback, foil);
|
||||
cardPanel.setCardBounds(0, 0, dimension.frameWidth, dimension.frameHeight);
|
||||
cardPanel.setCardBounds(0, 0, dimension.width, dimension.height);
|
||||
boolean implemented = !permanent.getRarity().equals(mage.Constants.Rarity.NA);
|
||||
cardPanel.setShowCastingCost(implemented);
|
||||
return cardPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagePermanent getMageCard(CardView permanent, CardDimensions dimension, UUID gameId, ActionCallback callback, boolean canBeFoil) {
|
||||
public MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil) {
|
||||
boolean foil = canBeFoil && (new Random()).nextInt(5) == 0;
|
||||
CardPanel cardPanel = new CardPanel(permanent, gameId, true, callback, foil);
|
||||
cardPanel.setCardBounds(0, 0, dimension.frameWidth, dimension.frameHeight);
|
||||
cardPanel.setCardBounds(0, 0, dimension.width, dimension.height);
|
||||
boolean implemented = !permanent.getRarity().equals(mage.Constants.Rarity.NA);
|
||||
cardPanel.setShowCastingCost(implemented);
|
||||
return cardPanel;
|
||||
|
@ -158,7 +158,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
cardWidth = cardWidthMax;
|
||||
Rectangle rect = jScrollPane.getVisibleRect();
|
||||
playAreaWidth = rect.width;
|
||||
playAreaHeight = rect.height - MW_GUIDE_HEIGHT;
|
||||
playAreaHeight = rect.height;
|
||||
while (true) {
|
||||
rows.clear();
|
||||
cardHeight = Math.round(cardWidth * CardPanel.ASPECT_RATIO);
|
||||
|
|
Loading…
Reference in a new issue