From d245ce1ad2046a4338eaba3a9ce5a3cb53c7af40 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 16 Apr 2015 16:29:54 +0200 Subject: [PATCH] * Fixed that card name text was covered by next card beneath if cards are displayed close together (library search). --- Mage.Client/src/main/java/mage/client/cards/Card.java | 7 +++++++ .../src/main/java/mage/client/cards/CardArea.java | 6 ++++++ .../src/main/java/org/mage/card/arcane/CardPanel.java | 9 ++++++++- Mage.Common/src/mage/cards/MageCard.java | 2 ++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Mage.Client/src/main/java/mage/client/cards/Card.java b/Mage.Client/src/main/java/mage/client/cards/Card.java index 2e7b1271a4..ca322655e8 100644 --- a/Mage.Client/src/main/java/mage/client/cards/Card.java +++ b/Mage.Client/src/main/java/mage/client/cards/Card.java @@ -534,4 +534,11 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis @Override public void setChoosable(boolean isChoosable) { } + + @Override + public void setTextOffset(int yOffset) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + } diff --git a/Mage.Client/src/main/java/mage/client/cards/CardArea.java b/Mage.Client/src/main/java/mage/client/cards/CardArea.java index 3ef731a0cc..1d40d21f80 100644 --- a/Mage.Client/src/main/java/mage/client/cards/CardArea.java +++ b/Mage.Client/src/main/java/mage/client/cards/CardArea.java @@ -50,6 +50,7 @@ public class CardArea extends JPanel { private boolean reloaded = false; private final javax.swing.JLayeredPane cardArea; private final javax.swing.JScrollPane scrollPane; + private int yTextOffset; /** * Create the panel. @@ -62,6 +63,7 @@ public class CardArea extends JPanel { cardArea = new JLayeredPane(); scrollPane.setViewportView(cardArea); + yTextOffset = 10; } @@ -82,9 +84,11 @@ public class CardArea extends JPanel { this.reloaded = true; cardArea.removeAll(); if (showCards != null && showCards.size() < 10) { + yTextOffset = 10; loadCardsFew(showCards, bigCard, gameId, listener); } else { + yTextOffset = 0; loadCardsMany(showCards, bigCard, gameId, listener, dimension); } cardArea.revalidate(); @@ -96,6 +100,7 @@ public class CardArea extends JPanel { public void loadCardsNarrow(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, MouseListener listener) { this.reloaded = true; cardArea.removeAll(); + yTextOffset = 0; loadCardsMany(showCards, bigCard, gameId, listener, dimension); cardArea.revalidate(); @@ -132,6 +137,7 @@ public class CardArea extends JPanel { cardArea.moveToFront(cardImg); cardImg.update(card); cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.frameWidth, cardDimensions.frameHeight); + cardImg.setTextOffset(yTextOffset); cardImg.showCardTitle(); } diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java index 48adcb0c46..fb14b5569d 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java @@ -150,6 +150,8 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti private JPanel cardArea; + private int yTextOffset = 10; + public CardPanel(CardView newGameCard, UUID gameId, final boolean loadImage, ActionCallback callback, final boolean foil, Dimension dimension) { this.gameCard = newGameCard; this.callback = callback; @@ -583,7 +585,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti ptText.setVisible(showText); int titleX = Math.round(cardWidth * (20f / 480)); - int titleY = Math.round(cardHeight * (9f / 680)) + 10; // TODO: Set to 0 if it's a card selection with small card offset (ike library search) + int titleY = Math.round(cardHeight * (9f / 680)) + yTextOffset; titleText.setBounds(cardXOffset + titleX, cardYOffset + titleY, cardWidth - titleX, cardHeight - titleY); Dimension ptSize = ptText.getPreferredSize(); @@ -1203,5 +1205,10 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti public void componentHidden(ComponentEvent ce) { } + @Override + public void setTextOffset(int yOffset) { + yTextOffset = yOffset; + } + } diff --git a/Mage.Common/src/mage/cards/MageCard.java b/Mage.Common/src/mage/cards/MageCard.java index 5d15dcda33..320e9d1139 100644 --- a/Mage.Common/src/mage/cards/MageCard.java +++ b/Mage.Common/src/mage/cards/MageCard.java @@ -17,6 +17,8 @@ public abstract class MageCard extends JPanel { public abstract void setAlpha(float transparency); public abstract float getAlpha(); public abstract CardView getOriginal(); + // sets the vertical text offset for the card name on the image + public abstract void setTextOffset(int yOffset); public abstract void setCardBounds(int x, int y, int width, int height); public abstract void update(CardView card); public abstract void updateImage();