forked from External/mage
replace public fields with encapsulation
This commit is contained in:
parent
d1e319787c
commit
8319fbf9ad
26 changed files with 544 additions and 327 deletions
|
|
@ -77,7 +77,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
this.gameId = gameId;
|
||||
this.card = card;
|
||||
this.bigCard = bigCard;
|
||||
small = new BufferedImage(Config.dimensions.frameWidth, Config.dimensions.frameHeight, BufferedImage.TYPE_INT_RGB);
|
||||
small = new BufferedImage(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight(), BufferedImage.TYPE_INT_RGB);
|
||||
backgroundName = getBackgroundName();
|
||||
background = ImageHelper.getBackground(card, backgroundName);
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
|
||||
gSmall.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
gSmall.setColor(Color.BLACK);
|
||||
gSmall.drawImage(ImageHelper.scaleImage(image, Config.dimensions.frameWidth, Config.dimensions.frameHeight), 0, 0, this);
|
||||
gSmall.drawImage(ImageHelper.scaleImage(image, Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight()), 0, 0, this);
|
||||
|
||||
gImage.setFont(new Font("Arial", Font.PLAIN, NAME_FONT_MAX_SIZE));
|
||||
gImage.drawString(card.getName()+"TEST", CONTENT_MAX_XOFFSET, NAME_MAX_YOFFSET);
|
||||
|
|
@ -145,16 +145,16 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
|
||||
gImage.dispose();
|
||||
|
||||
gSmall.setFont(new Font("Arial", Font.PLAIN, Config.dimensions.nameFontSize));
|
||||
gSmall.drawString(card.getName()+"TEST2", Config.dimensions.contentXOffset, Config.dimensions.nameYOffset);
|
||||
gSmall.setFont(new Font("Arial", Font.PLAIN, Config.dimensions.getNameFontSize()));
|
||||
gSmall.drawString(card.getName()+"TEST2", Config.dimensions.getContentXOffset(), Config.dimensions.getNameYOffset());
|
||||
if (card.isCreature()) {
|
||||
gSmall.drawString(card.getPower() + "/-/" + card.getToughness(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
|
||||
gSmall.drawString(card.getPower() + "/-/" + card.getToughness(), Config.dimensions.getPowBoxTextLeft(), Config.dimensions.getPowBoxTextTop());
|
||||
} else if (card.isPlanesWalker()) {
|
||||
gSmall.drawString(card.getLoyalty(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
|
||||
gSmall.drawString(card.getLoyalty(), Config.dimensions.getPowBoxTextLeft(), Config.dimensions.getPowBoxTextTop());
|
||||
}
|
||||
|
||||
if (!card.getCardTypes().isEmpty()) {
|
||||
gSmall.drawString(cardType, Config.dimensions.contentXOffset, Config.dimensions.typeYOffset);
|
||||
gSmall.drawString(cardType, Config.dimensions.getContentXOffset(), Config.dimensions.getTypeYOffset());
|
||||
}
|
||||
drawText();
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
|
||||
setMinimumSize(getPreferredSize());
|
||||
setOpaque(false);
|
||||
setPreferredSize(new Dimension(dimension.frameWidth, dimension.frameHeight));
|
||||
setPreferredSize(new Dimension(dimension.getFrameWidth(), dimension.getFrameHeight()));
|
||||
setLayout(null);
|
||||
|
||||
jScrollPane1.setBorder(null);
|
||||
|
|
@ -304,7 +304,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
|
||||
add(jScrollPane1);
|
||||
jScrollPane1.setBounds(20, 110, 130, 100);
|
||||
jScrollPane1.setBounds(new Rectangle(dimension.contentXOffset, dimension.textYOffset, dimension.textWidth, dimension.textHeight));
|
||||
jScrollPane1.setBounds(new Rectangle(dimension.getContentXOffset(), dimension.getTextYOffset(), dimension.getTextWidth(), dimension.getTextHeight()));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
@Override
|
||||
|
|
@ -355,11 +355,11 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
tooltipPopup.hide();
|
||||
}
|
||||
PopupFactory factory = PopupFactory.getSharedInstance();
|
||||
tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + Config.dimensions.frameWidth, (int) this.getLocationOnScreen().getY() + 40);
|
||||
tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + Config.dimensions.getFrameWidth(), (int) this.getLocationOnScreen().getY() + 40);
|
||||
tooltipPopup.show();
|
||||
//hack to get tooltipPopup to resize to fit text
|
||||
tooltipPopup.hide();
|
||||
tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + Config.dimensions.frameWidth, (int) this.getLocationOnScreen().getY() + 40);
|
||||
tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + Config.dimensions.getFrameWidth(), (int) this.getLocationOnScreen().getY() + 40);
|
||||
tooltipPopup.show();
|
||||
tooltipShowing = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ public class Cards extends javax.swing.JPanel {
|
|||
|
||||
private Dimension getCardDimension() {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
|
||||
}
|
||||
return cardDimension;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
|||
for (int i = 1; i < maxRows; i++) {
|
||||
scale = (double) (this.getHeight()/i) / Constants.FRAME_MAX_HEIGHT;
|
||||
cardDimension = new CardDimensions(scale);
|
||||
maxCards = this.getWidth() / (cardDimension.frameWidth + offsetX);
|
||||
maxCards = this.getWidth() / (cardDimension.getFrameWidth() + offsetX);
|
||||
if ((maxCards * i) >= booster.size()) {
|
||||
numColumns = booster.size() / i;
|
||||
if (booster.size() % i > 0) {
|
||||
|
|
@ -95,8 +95,8 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
|||
}
|
||||
|
||||
if (cardDimension != null) {
|
||||
Rectangle rectangle = new Rectangle(cardDimension.frameWidth, cardDimension.frameHeight);
|
||||
Dimension dimension = new Dimension(cardDimension.frameWidth, cardDimension.frameHeight);
|
||||
Rectangle rectangle = new Rectangle(cardDimension.getFrameWidth(), cardDimension.getFrameHeight());
|
||||
Dimension dimension = new Dimension(cardDimension.getFrameWidth(), cardDimension.getFrameHeight());
|
||||
|
||||
List<CardView> sortedCards = new ArrayList<>(booster.values());
|
||||
sortedCards.sort(new CardViewRarityComparator());
|
||||
|
|
@ -105,7 +105,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
|||
cardImg.addMouseListener(this);
|
||||
add(cardImg);
|
||||
cardImg.update(card);
|
||||
rectangle.setLocation(curColumn * (cardDimension.frameWidth + offsetX) + offsetX, curRow * (rectangle.height + offsetY) + offsetY);
|
||||
rectangle.setLocation(curColumn * (cardDimension.getFrameWidth() + offsetX) + offsetX, curRow * (rectangle.height + offsetY) + offsetY);
|
||||
|
||||
cardImg.setBounds(rectangle);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class Permanent extends Card {
|
|||
super(permanent, bigCard, dimensions, gameId);
|
||||
this.setSize(this.getPreferredSize());
|
||||
this.permanent = permanent;
|
||||
tappedImage = new BufferedImage(Config.dimensions.frameHeight, Config.dimensions.frameWidth, BufferedImage.TYPE_INT_RGB);
|
||||
tappedImage = new BufferedImage(Config.dimensions.getFrameHeight(), Config.dimensions.getFrameWidth(), BufferedImage.TYPE_INT_RGB);
|
||||
}
|
||||
|
||||
public UUID getPermanentId() {
|
||||
|
|
@ -173,10 +173,10 @@ public class Permanent extends Card {
|
|||
g2.setColor(Color.BLACK);
|
||||
}
|
||||
if (permanent.isTapped()) {
|
||||
g2.drawRect(0, 0, Config.dimensions.frameHeight - 1, Config.dimensions.frameWidth - 1);
|
||||
g2.drawRect(0, 0, Config.dimensions.getFrameHeight() - 1, Config.dimensions.getFrameWidth() - 1);
|
||||
}
|
||||
else {
|
||||
g2.drawRect(0, 0, Config.dimensions.frameWidth - 1, Config.dimensions.frameHeight - 1);
|
||||
g2.drawRect(0, 0, Config.dimensions.getFrameWidth() - 1, Config.dimensions.getFrameHeight() - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -185,7 +185,7 @@ public class Permanent extends Card {
|
|||
Graphics2D g = (Graphics2D) tappedImage.getGraphics();
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
g.drawImage(TransformedImageCache.getRotatedResizedImage(small, dimension.frameWidth, dimension.frameHeight, Math.toRadians(90.0)), 0, 0, this);
|
||||
g.drawImage(TransformedImageCache.getRotatedResizedImage(small, dimension.getFrameWidth(), dimension.getFrameHeight(), Math.toRadians(90.0)), 0, 0, this);
|
||||
|
||||
g.dispose();
|
||||
}
|
||||
|
|
@ -206,10 +206,10 @@ public class Permanent extends Card {
|
|||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
if (permanent != null && permanent.isTapped()) {
|
||||
return new Dimension(Config.dimensions.frameHeight, Config.dimensions.frameWidth);
|
||||
return new Dimension(Config.dimensions.getFrameHeight(), Config.dimensions.getFrameWidth());
|
||||
}
|
||||
else {
|
||||
return new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
return new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -229,7 +229,7 @@ public class Permanent extends Card {
|
|||
tooltipPopup.hide();
|
||||
}
|
||||
PopupFactory factory = PopupFactory.getSharedInstance();
|
||||
int x = (int) this.getLocationOnScreen().getX() + (permanent.isTapped()?Config.dimensions.frameHeight:Config.dimensions.frameWidth);
|
||||
int x = (int) this.getLocationOnScreen().getX() + (permanent.isTapped()? Config.dimensions.getFrameHeight() : Config.dimensions.getFrameWidth());
|
||||
int y = (int) this.getLocationOnScreen().getY() + 40;
|
||||
tooltipPopup = factory.getPopup(this, tooltipText, x, y);
|
||||
tooltipPopup.show();
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public abstract class IDialogPanel extends JXPanel {
|
|||
|
||||
protected Dimension getCardDimension() {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
|
||||
}
|
||||
return cardDimension;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ public class MageBook extends JComponent {
|
|||
|
||||
// calculate the x offset of the second (right) page
|
||||
int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH)
|
||||
- (cardDimensions.frameWidth + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X;
|
||||
- (cardDimensions.getFrameWidth() + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X;
|
||||
|
||||
rectangle.setLocation(second_page_x, OFFSET_Y);
|
||||
for (int i = conf.CARDS_PER_PAGE / 2; i < min(conf.CARDS_PER_PAGE, size); i++) {
|
||||
|
|
@ -277,7 +277,7 @@ public class MageBook extends JComponent {
|
|||
|
||||
// calculate the x offset of the second (right) page
|
||||
int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH)
|
||||
- (cardDimensions.frameWidth + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X;
|
||||
- (cardDimensions.getFrameWidth() + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X;
|
||||
|
||||
rectangle.setLocation(second_page_x, OFFSET_Y);
|
||||
for (int i = conf.CARDS_PER_PAGE / 2; i < min(conf.CARDS_PER_PAGE, size); i++) {
|
||||
|
|
@ -302,7 +302,7 @@ public class MageBook extends JComponent {
|
|||
rectangle.translate(OFFSET_X, OFFSET_Y);
|
||||
// calculate the x offset of the second (right) page
|
||||
int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH)
|
||||
- (cardDimensions.frameWidth + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X;
|
||||
- (cardDimensions.getFrameWidth() + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X;
|
||||
|
||||
// Already have numTokens tokens presented. Appending the emblems to the end of these.
|
||||
numTokens = numTokens % conf.CARDS_PER_PAGE;
|
||||
|
|
@ -358,7 +358,7 @@ public class MageBook extends JComponent {
|
|||
rectangle.translate(OFFSET_X, OFFSET_Y);
|
||||
|
||||
int second_page_x = (conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH)
|
||||
- (cardDimensions.frameWidth + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X;
|
||||
- (cardDimensions.getFrameWidth() + CardPosition.GAP_X) * conf.CARD_COLUMNS + CardPosition.GAP_X - OFFSET_X;
|
||||
|
||||
numTokensEmblems = numTokensEmblems % conf.CARDS_PER_PAGE;
|
||||
if (numTokensEmblems < conf.CARDS_PER_PAGE / 2) {
|
||||
|
|
@ -404,20 +404,20 @@ public class MageBook extends JComponent {
|
|||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
|
||||
}
|
||||
final MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true);
|
||||
cardImg.setBounds(rectangle);
|
||||
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
|
||||
cardImg.update(card);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.frameWidth, cardDimensions.frameHeight);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.getFrameWidth(), cardDimensions.getFrameHeight());
|
||||
|
||||
cardImg.setCardCaptionTopOffset(8); // card caption below real card caption to see full name even with mana icons
|
||||
|
||||
// card number label
|
||||
JLabel cardNumber = new JLabel();
|
||||
int dy = -5; // image panel have empty space in bottom (bug?), need to move label up
|
||||
cardNumber.setBounds(rectangle.x, rectangle.y + cardImg.getHeight() + dy, cardDimensions.frameWidth, 20);
|
||||
cardNumber.setBounds(rectangle.x, rectangle.y + cardImg.getHeight() + dy, cardDimensions.getFrameWidth(), 20);
|
||||
cardNumber.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
//cardNumber.setBorder(BorderFactory.createLineBorder(new Color(180, 50, 150), 3, true));
|
||||
cardNumber.setFont(jLayeredPane.getFont().deriveFont(jLayeredPane.getFont().getStyle() | Font.BOLD));
|
||||
|
|
@ -427,7 +427,7 @@ public class MageBook extends JComponent {
|
|||
// draft rating label (
|
||||
JLabel draftRating = new JLabel();
|
||||
dy = -5 * 2 + cardNumber.getHeight(); // under card number
|
||||
draftRating.setBounds(rectangle.x, rectangle.y + cardImg.getHeight() + dy, cardDimensions.frameWidth, 20);
|
||||
draftRating.setBounds(rectangle.x, rectangle.y + cardImg.getHeight() + dy, cardDimensions.getFrameWidth(), 20);
|
||||
draftRating.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
//draftRating.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 150), 3, true));
|
||||
draftRating.setFont(jLayeredPane.getFont().deriveFont(jLayeredPane.getFont().getStyle() | Font.BOLD));
|
||||
|
|
@ -441,7 +441,7 @@ public class MageBook extends JComponent {
|
|||
|
||||
private void addToken(Token token, BigCard bigCard, UUID gameId, Rectangle rectangle) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
|
||||
}
|
||||
PermanentToken newToken = new PermanentToken(token, null, token.getOriginalExpansionSetCode(), null);
|
||||
newToken.removeSummoningSickness();
|
||||
|
|
@ -451,7 +451,7 @@ public class MageBook extends JComponent {
|
|||
cardImg.setBounds(rectangle);
|
||||
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
|
||||
cardImg.update(theToken);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.frameWidth, cardDimensions.frameHeight);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.getFrameWidth(), cardDimensions.getFrameHeight());
|
||||
}
|
||||
|
||||
private void addEmblem(Emblem emblem, BigCard bigCard, UUID gameId, Rectangle rectangle) {
|
||||
|
|
@ -855,8 +855,8 @@ public class MageBook extends JComponent {
|
|||
|
||||
public static Rectangle translatePosition(int index, Rectangle r, Configuration conf) {
|
||||
Rectangle rect = new Rectangle(r);
|
||||
rect.translate((cardDimensions.frameWidth + GAP_X) * conf.dx[index],
|
||||
(cardDimensions.frameHeight + GAP_Y) * conf.dy[index]);
|
||||
rect.translate((cardDimensions.getFrameWidth() + GAP_X) * conf.dx[index],
|
||||
(cardDimensions.getFrameHeight() + GAP_Y) * conf.dy[index]);
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -249,8 +249,8 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth,
|
||||
Config.dimensions.frameHeight);
|
||||
cardDimension = new Dimension(Config.dimensions.getFrameWidth(),
|
||||
Config.dimensions.getFrameHeight());
|
||||
}
|
||||
cards.put(card.getId(), card);
|
||||
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
|
||||
private void addPermanent(PermanentView permanent, final int count) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
|
||||
}
|
||||
final MagePermanent perm = Plugins.instance.getMagePermanent(permanent, bigCard, cardDimension, gameId, true);
|
||||
if (!Plugins.instance.isCardPluginLoaded()) {
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
}
|
||||
|
||||
private void showTooltipPopup(final TransferData data, final Component parentComponent, final Point parentPoint) {
|
||||
if (data.component != null) {
|
||||
if (data.getComponent() != null) {
|
||||
tooltipDelay = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_DELAY, 300);
|
||||
if (tooltipDelay == 0) {
|
||||
return;
|
||||
|
|
@ -120,18 +120,18 @@ public class MageActionCallback implements ActionCallback {
|
|||
|
||||
if (cardInfoPane == null) {
|
||||
PopupFactory factory = PopupFactory.getSharedInstance();
|
||||
if (data.locationOnScreen == null) {
|
||||
if (data.component == null) {
|
||||
if (data.getLocationOnScreen() == null) {
|
||||
if (data.getComponent() == null) {
|
||||
return;
|
||||
}
|
||||
data.locationOnScreen = data.component.getLocationOnScreen();
|
||||
data.setLocationOnScreen(data.getComponent().getLocationOnScreen());
|
||||
}
|
||||
data.popupText.updateText();
|
||||
tooltipPopup = factory.getPopup(data.component, data.popupText, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40);
|
||||
data.getPopupText().updateText();
|
||||
tooltipPopup = factory.getPopup(data.getComponent(), data.getPopupText(), (int) data.getLocationOnScreen().getX() + data.getPopupOffsetX(), (int) data.getLocationOnScreen().getY() + data.getPopupOffsetY() + 40);
|
||||
tooltipPopup.show();
|
||||
// hack to get popup to resize to fit text
|
||||
tooltipPopup.hide();
|
||||
tooltipPopup = factory.getPopup(data.component, data.popupText, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40);
|
||||
tooltipPopup = factory.getPopup(data.getComponent(), data.getPopupText(), (int) data.getLocationOnScreen().getX() + data.getPopupOffsetX(), (int) data.getLocationOnScreen().getY() + data.getPopupOffsetY() + 40);
|
||||
tooltipPopup.show();
|
||||
} else {
|
||||
sumbitShowPopupTask(data, parentComponent, parentPoint);
|
||||
|
|
@ -145,7 +145,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
ThreadUtils.sleep(tooltipDelay);
|
||||
|
||||
if (tooltipCard == null
|
||||
|| !tooltipCard.equals(data.card)
|
||||
|| !tooltipCard.equals(data.getCard())
|
||||
|| SessionHandler.getSession() == null
|
||||
|| !popupTextWindowOpen
|
||||
|| enlargedWindowState != EnlargedWindowState.CLOSED) {
|
||||
|
|
@ -156,7 +156,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
final Component popupContainer = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
|
||||
Component popup2 = MageFrame.getUI().getComponent(MageComponents.CARD_INFO_PANE);
|
||||
|
||||
((CardInfoPane) popup2).setCard(data.card, popupContainer);
|
||||
((CardInfoPane) popup2).setCard(data.getCard(), popupContainer);
|
||||
|
||||
showPopup(popupContainer, popup2);
|
||||
|
||||
|
|
@ -172,11 +172,11 @@ public class MageActionCallback implements ActionCallback {
|
|||
|| enlargedWindowState != EnlargedWindowState.CLOSED) {
|
||||
return;
|
||||
}
|
||||
if (data.locationOnScreen == null) {
|
||||
data.locationOnScreen = data.component.getLocationOnScreen();
|
||||
if (data.getLocationOnScreen() == null) {
|
||||
data.setLocationOnScreen(data.getComponent().getLocationOnScreen());
|
||||
}
|
||||
|
||||
Point location = new Point((int) data.locationOnScreen.getX() + data.popupOffsetX - 40, (int) data.locationOnScreen.getY() + data.popupOffsetY - 40);
|
||||
Point location = new Point((int) data.getLocationOnScreen().getX() + data.getPopupOffsetX() - 40, (int) data.getLocationOnScreen().getY() + data.getPopupOffsetY() - 40);
|
||||
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, infoPane, parentComponent);
|
||||
location.translate(-parentPoint.x, -parentPoint.y);
|
||||
popupContainer.setLocation(location);
|
||||
|
|
@ -190,7 +190,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e, TransferData data) {
|
||||
data.component.requestFocusInWindow();
|
||||
data.getComponent().requestFocusInWindow();
|
||||
|
||||
// for some reason sometime mouseRelease happens before numerous Mouse_Dragged events
|
||||
// that results in not finished dragging
|
||||
|
|
@ -201,23 +201,23 @@ public class MageActionCallback implements ActionCallback {
|
|||
prevCardPanel = null;
|
||||
cardPanels.clear();
|
||||
Point mouse = new Point(e.getX(), e.getY());
|
||||
SwingUtilities.convertPointToScreen(mouse, data.component);
|
||||
SwingUtilities.convertPointToScreen(mouse, data.getComponent());
|
||||
initialMousePos = new Point((int) mouse.getX(), (int) mouse.getY());
|
||||
initialCardPos = data.component.getLocation();
|
||||
initialCardPos = data.getComponent().getLocation();
|
||||
// Closes popup & enlarged view if a card/Permanent is selected
|
||||
hideTooltipPopup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e, TransferData transferData) {
|
||||
CardPanel card = ((CardPanel) transferData.component);
|
||||
CardPanel card = ((CardPanel) transferData.getComponent());
|
||||
if (e.isPopupTrigger() /*&& card.getPopupMenu() != null*/) {
|
||||
hideTooltipPopup();
|
||||
} else if (card.getZone() != null && card.getZone().equalsIgnoreCase("hand")) {
|
||||
int maxXOffset = 0;
|
||||
if (isDragging) {
|
||||
Point mouse = new Point(e.getX(), e.getY());
|
||||
SwingUtilities.convertPointToScreen(mouse, transferData.component);
|
||||
SwingUtilities.convertPointToScreen(mouse, transferData.getComponent());
|
||||
maxXOffset = Math.abs((int) (mouse.getX() - initialMousePos.x));
|
||||
}
|
||||
|
||||
|
|
@ -225,15 +225,15 @@ public class MageActionCallback implements ActionCallback {
|
|||
|
||||
this.startedDragging = false;
|
||||
if (maxXOffset < MIN_X_OFFSET_REQUIRED) { // we need this for protection from small card movements
|
||||
transferData.component.requestFocusInWindow();
|
||||
DefaultActionCallback.instance.mouseClicked(transferData.gameId, transferData.card);
|
||||
transferData.getComponent().requestFocusInWindow();
|
||||
DefaultActionCallback.instance.mouseClicked(transferData.getGameId(), transferData.getCard());
|
||||
// Closes popup & enlarged view if a card/Permanent is selected
|
||||
hideTooltipPopup();
|
||||
}
|
||||
e.consume();
|
||||
} else {
|
||||
transferData.component.requestFocusInWindow();
|
||||
DefaultActionCallback.instance.mouseClicked(transferData.gameId, transferData.card);
|
||||
transferData.getComponent().requestFocusInWindow();
|
||||
DefaultActionCallback.instance.mouseClicked(transferData.getGameId(), transferData.getCard());
|
||||
// Closes popup & enlarged view if a card/Permanent is selected
|
||||
hideTooltipPopup();
|
||||
e.consume();
|
||||
|
|
@ -261,7 +261,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
if (!Plugins.instance.isCardPluginLoaded()) {
|
||||
return;
|
||||
}
|
||||
if (!popupData.card.equals(transferData.card)) {
|
||||
if (!popupData.getCard().equals(transferData.getCard())) {
|
||||
this.popupData = transferData;
|
||||
handleOverNewView(transferData);
|
||||
|
||||
|
|
@ -274,7 +274,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e, TransferData transferData) {
|
||||
CardPanel cardPanel = ((CardPanel) transferData.component);
|
||||
CardPanel cardPanel = ((CardPanel) transferData.getComponent());
|
||||
if (cardPanel.getZone() == null || !cardPanel.getZone().equalsIgnoreCase("hand")) {
|
||||
// drag'n'drop is allowed for HAND zone only
|
||||
return;
|
||||
|
|
@ -287,7 +287,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
prevCardPanel = cardPanel;
|
||||
Point cardPanelLocationOld = cardPanel.getLocation();
|
||||
Point mouse = new Point(e.getX(), e.getY());
|
||||
SwingUtilities.convertPointToScreen(mouse, transferData.component);
|
||||
SwingUtilities.convertPointToScreen(mouse, transferData.getComponent());
|
||||
int xOffset = cardPanel.getXOffset(cardPanel.getCardWidth());
|
||||
int newX = Math.max(initialCardPos.x + (int) (mouse.getX() - initialMousePos.x) - xOffset, 0);
|
||||
cardPanel.setCardBounds(
|
||||
|
|
@ -306,7 +306,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
@Override
|
||||
public void mouseExited(MouseEvent e, final TransferData data) {
|
||||
if (data != null) {
|
||||
hideAll(data.gameId);
|
||||
hideAll(data.getGameId());
|
||||
} else {
|
||||
hideAll(null);
|
||||
}
|
||||
|
|
@ -362,20 +362,20 @@ public class MageActionCallback implements ActionCallback {
|
|||
// Prevent to show tooltips from panes not in front
|
||||
MagePane topPane = MageFrame.getTopMost(null);
|
||||
if (topPane instanceof GamePane) {
|
||||
if (!((GamePane) topPane).getGameId().equals(data.gameId)) {
|
||||
if (!((GamePane) topPane).getGameId().equals(data.getGameId())) {
|
||||
return;
|
||||
}
|
||||
} else if (data.gameId != null) {
|
||||
} else if (data.getGameId() != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
hideTooltipPopup();
|
||||
cancelTimeout();
|
||||
Component parentComponent = SwingUtilities.getRoot(data.component);
|
||||
Component parentComponent = SwingUtilities.getRoot(data.getComponent());
|
||||
Point parentPoint = parentComponent.getLocationOnScreen();
|
||||
|
||||
if (data.locationOnScreen == null) {
|
||||
data.locationOnScreen = data.component.getLocationOnScreen();
|
||||
if (data.getLocationOnScreen() == null) {
|
||||
data.setLocationOnScreen(data.getComponent().getLocationOnScreen());
|
||||
}
|
||||
|
||||
ArrowUtil.drawArrowsForTargets(data, parentPoint);
|
||||
|
|
@ -383,12 +383,12 @@ public class MageActionCallback implements ActionCallback {
|
|||
ArrowUtil.drawArrowsForPairedCards(data, parentPoint);
|
||||
ArrowUtil.drawArrowsForBandedCards(data, parentPoint);
|
||||
ArrowUtil.drawArrowsForEnchantPlayers(data, parentPoint);
|
||||
tooltipCard = data.card;
|
||||
tooltipCard = data.getCard();
|
||||
showTooltipPopup(data, parentComponent, parentPoint);
|
||||
}
|
||||
|
||||
private void handlePopup(TransferData transferData) {
|
||||
MageCard mageCard = (MageCard) transferData.component;
|
||||
MageCard mageCard = (MageCard) transferData.getComponent();
|
||||
if (!popupTextWindowOpen
|
||||
|| !Objects.equals(mageCard.getOriginal().getId(), bigCard.getCardId())) {
|
||||
if (bigCard.getWidth() > 0) {
|
||||
|
|
@ -502,7 +502,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
this.enlargeMode = showAlternative;
|
||||
CardView cardView = null;
|
||||
if (popupData != null) {
|
||||
cardView = popupData.card;
|
||||
cardView = popupData.getCard();
|
||||
}
|
||||
if (this.popupTextWindowOpen) {
|
||||
hideTooltipPopup();
|
||||
|
|
@ -566,17 +566,17 @@ public class MageActionCallback implements ActionCallback {
|
|||
}
|
||||
final Component popupContainer = MageFrame.getUI().getComponent(mageComponentCardPreviewContainer);
|
||||
Component cardPreviewPane = MageFrame.getUI().getComponent(mageComponentCardPreviewPane);
|
||||
Component parentComponent = SwingUtilities.getRoot(transferData.component);
|
||||
Component parentComponent = SwingUtilities.getRoot(transferData.getComponent());
|
||||
if (cardPreviewPane != null && parentComponent != null) {
|
||||
Point parentPoint = parentComponent.getLocationOnScreen();
|
||||
transferData.locationOnScreen = transferData.component.getLocationOnScreen();
|
||||
Point location = new Point((int) transferData.locationOnScreen.getX() + transferData.popupOffsetX - 40, (int) transferData.locationOnScreen.getY() + transferData.popupOffsetY - 40);
|
||||
transferData.setLocationOnScreen(transferData.getComponent().getLocationOnScreen());
|
||||
Point location = new Point((int) transferData.getLocationOnScreen().getX() + transferData.getPopupOffsetX() - 40, (int) transferData.getLocationOnScreen().getY() + transferData.getPopupOffsetY() - 40);
|
||||
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, cardPreviewPane, parentComponent);
|
||||
location.translate(-parentPoint.x, -parentPoint.y);
|
||||
popupContainer.setLocation(location);
|
||||
popupContainer.setVisible(true);
|
||||
|
||||
MageCard mageCard = (MageCard) transferData.component;
|
||||
MageCard mageCard = (MageCard) transferData.getComponent();
|
||||
Image image = null;
|
||||
switch (enlargeMode) {
|
||||
case COPY:
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ public class CombatGroup extends javax.swing.JPanel {
|
|||
attackers = new mage.client.cards.Cards();
|
||||
lblDefender = new javax.swing.JLabel();
|
||||
|
||||
blockers.setPreferredSize(new java.awt.Dimension(Config.dimensions.frameWidth + 8, Config.dimensions.frameHeight + 25));
|
||||
blockers.setPreferredSize(new java.awt.Dimension(Config.dimensions.getFrameWidth() + 8, Config.dimensions.getFrameHeight() + 25));
|
||||
|
||||
attackers.setPreferredSize(new java.awt.Dimension(Config.dimensions.frameWidth + 8, Config.dimensions.frameHeight + 25));
|
||||
attackers.setPreferredSize(new java.awt.Dimension(Config.dimensions.getFrameWidth() + 8, Config.dimensions.getFrameHeight() + 25));
|
||||
|
||||
lblDefender.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
lblDefender.setText("Defender");
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public final class IgnoreList {
|
|||
+ "<br/>\\unignore [username] - remove a username from your ignore list on this server.</font>";
|
||||
|
||||
public static final int MAX_IGNORE_LIST_SIZE = 50;
|
||||
public static Set<ChatMessage.MessageType> IGNORED_MESSAGE_TYPES
|
||||
public static final Set<ChatMessage.MessageType> IGNORED_MESSAGE_TYPES
|
||||
= ImmutableSet.of(ChatMessage.MessageType.TALK,
|
||||
ChatMessage.MessageType.WHISPER_FROM);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,32 +19,32 @@ public final class ArrowUtil {
|
|||
private ArrowUtil() {}
|
||||
|
||||
public static void drawArrowsForPairedCards(TransferData data, Point parentPoint) {
|
||||
if (data.card.getPairedCard() != null) {
|
||||
Point me = new Point(data.locationOnScreen);
|
||||
if (data.getCard().getPairedCard() != null) {
|
||||
Point me = new Point(data.getLocationOnScreen());
|
||||
me.translate(-parentPoint.x, -parentPoint.y);
|
||||
UUID uuid = data.card.getPairedCard();
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
||||
UUID uuid = data.getCard().getPairedCard();
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.getGameId()).getPlayers().values()) {
|
||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||
if (permanent != null) {
|
||||
Point target = permanent.getLocationOnScreen();
|
||||
target.translate(-parentPoint.x, -parentPoint.y);
|
||||
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() + 10, Color.green, ArrowBuilder.Type.PAIRED);
|
||||
ArrowBuilder.getBuilder().addArrow(data.getGameId(), (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() + 10, Color.green, ArrowBuilder.Type.PAIRED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawArrowsForBandedCards(TransferData data, Point parentPoint) {
|
||||
if (data.card.getBandedCards() != null && !data.card.getBandedCards().isEmpty()) {
|
||||
Point me = new Point(data.locationOnScreen);
|
||||
if (data.getCard().getBandedCards() != null && !data.getCard().getBandedCards().isEmpty()) {
|
||||
Point me = new Point(data.getLocationOnScreen());
|
||||
me.translate(-parentPoint.x, -parentPoint.y);
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
||||
for (UUID uuid : data.card.getBandedCards()) {
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.getGameId()).getPlayers().values()) {
|
||||
for (UUID uuid : data.getCard().getBandedCards()) {
|
||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||
if (permanent != null) {
|
||||
Point target = permanent.getLocationOnScreen();
|
||||
target.translate(-parentPoint.x, -parentPoint.y);
|
||||
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) me.getX() + 55, (int) me.getY() + 25, (int) target.getX() + 60, (int) target.getY() + 35, Color.yellow, ArrowBuilder.Type.BANDED);
|
||||
ArrowBuilder.getBuilder().addArrow(data.getGameId(), (int) me.getX() + 55, (int) me.getY() + 25, (int) target.getX() + 60, (int) target.getY() + 35, Color.yellow, ArrowBuilder.Type.BANDED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -52,17 +52,17 @@ public final class ArrowUtil {
|
|||
}
|
||||
|
||||
public static void drawArrowsForEnchantPlayers(TransferData data, Point parentPoint) {
|
||||
if (data.gameId != null && MageFrame.getGame(data.gameId) != null) {
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
||||
if (data.getGameId() != null && MageFrame.getGame(data.getGameId()) != null) {
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.getGameId()).getPlayers().values()) {
|
||||
PlayerPanelExt playAreaPanel = pa.getPlayerPanel();
|
||||
if (playAreaPanel != null && playAreaPanel.getPlayer() != null && playAreaPanel.getPlayer().hasAttachments()) {
|
||||
Point me = new Point(data.locationOnScreen);
|
||||
Point me = new Point(data.getLocationOnScreen());
|
||||
me.translate(-parentPoint.x, -parentPoint.y);
|
||||
for (UUID attachmentId : playAreaPanel.getPlayer().getAttachments()) {
|
||||
if (attachmentId.equals(data.card.getId())) {
|
||||
if (attachmentId.equals(data.getCard().getId())) {
|
||||
Point player = pa.getLocationOnScreen();
|
||||
player.translate(-parentPoint.x, -parentPoint.y);
|
||||
ArrowBuilder.getBuilder().addArrow(data.gameId,(int) me.getX() + 35, (int) me.getY(), (int) player.getX() + 40, (int) player.getY() - 40, Color.magenta, ArrowBuilder.Type.ENCHANT_PLAYERS);
|
||||
ArrowBuilder.getBuilder().addArrow(data.getGameId(),(int) me.getX() + 35, (int) me.getY(), (int) player.getX() + 40, (int) player.getY() - 40, Color.magenta, ArrowBuilder.Type.ENCHANT_PLAYERS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -71,45 +71,45 @@ public final class ArrowUtil {
|
|||
}
|
||||
|
||||
public static void drawArrowsForSource(TransferData data, Point parentPoint) {
|
||||
if (data.card.isAbility()) {
|
||||
Point me = new Point(data.locationOnScreen);
|
||||
if (data.getCard().isAbility()) {
|
||||
Point me = new Point(data.getLocationOnScreen());
|
||||
me.translate(-parentPoint.x, -parentPoint.y);
|
||||
UUID uuid = data.card.getParentId();
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
||||
UUID uuid = data.getCard().getParentId();
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.getGameId()).getPlayers().values()) {
|
||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||
if (permanent != null) {
|
||||
Point source = permanent.getLocationOnScreen();
|
||||
source.translate(-parentPoint.x, -parentPoint.y);
|
||||
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) source.getX() + 40, (int) source.getY() + 10, (int) me.getX() + 35, (int) me.getY() + 20, Color.blue, ArrowBuilder.Type.SOURCE);
|
||||
ArrowBuilder.getBuilder().addArrow(data.getGameId(), (int) source.getX() + 40, (int) source.getY() + 10, (int) me.getX() + 35, (int) me.getY() + 20, Color.blue, ArrowBuilder.Type.SOURCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawArrowsForTargets(TransferData data, Point parentPoint) {
|
||||
java.util.List<UUID> targets = data.card.getTargets();
|
||||
java.util.List<UUID> targets = data.getCard().getTargets();
|
||||
if (targets == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Point me = new Point(data.locationOnScreen);
|
||||
Point me = new Point(data.getLocationOnScreen());
|
||||
me.translate(-parentPoint.x, -parentPoint.y);
|
||||
for (UUID uuid : targets) {
|
||||
|
||||
PlayAreaPanel p = MageFrame.getGame(data.gameId).getPlayers().get(uuid);
|
||||
PlayAreaPanel p = MageFrame.getGame(data.getGameId()).getPlayers().get(uuid);
|
||||
if (p != null) {
|
||||
Point target = p.getLocationOnScreen();
|
||||
target.translate(-parentPoint.x, -parentPoint.y);
|
||||
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() - 40, Color.red, ArrowBuilder.Type.TARGET);
|
||||
ArrowBuilder.getBuilder().addArrow(data.getGameId(), (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() - 40, Color.red, ArrowBuilder.Type.TARGET);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (PlayAreaPanel panel : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
||||
for (PlayAreaPanel panel : MageFrame.getGame(data.getGameId()).getPlayers().values()) {
|
||||
MagePermanent permanent = panel.getBattlefieldPanel().getPermanents().get(uuid);
|
||||
if (permanent != null) {
|
||||
Point target = permanent.getLocationOnScreen();
|
||||
target.translate(-parentPoint.x, -parentPoint.y);
|
||||
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() + 10, Color.red, ArrowBuilder.Type.TARGET);
|
||||
ArrowBuilder.getBuilder().addArrow(data.getGameId(), (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() + 10, Color.red, ArrowBuilder.Type.TARGET);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -117,12 +117,12 @@ public final class ArrowUtil {
|
|||
if (view != null) {
|
||||
CardsView graveyard = view.getGraveyard();
|
||||
if (graveyard.containsKey(uuid)) {
|
||||
p = MageFrame.getGame(data.gameId).getPlayers().get(view.getPlayerId());
|
||||
p = MageFrame.getGame(data.getGameId()).getPlayers().get(view.getPlayerId());
|
||||
if (p != null) {
|
||||
Point target = p.getLocationOnScreen();
|
||||
target.translate(-parentPoint.x, -parentPoint.y);
|
||||
int yOffset = p.isSmallMode() ? (PlayAreaPanel.PANEL_HEIGHT - PlayAreaPanel.PANEL_HEIGHT_SMALL) : 0;
|
||||
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 15, (int) target.getY() + 145 - yOffset, Color.red, ArrowBuilder.Type.TARGET);
|
||||
ArrowBuilder.getBuilder().addArrow(data.getGameId(), (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 15, (int) target.getY() + 145 - yOffset, Color.red, ArrowBuilder.Type.TARGET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ import java.util.Map;
|
|||
*/
|
||||
public class FastSearchUtil {
|
||||
|
||||
public static String DEFAULT_EXPANSION_SEARCH_MESSAGE = "Select set or expansion";
|
||||
public static String DEFAULT_EXPANSION_TOOLTIP_MESSAGE = "Fast search set or expansion";
|
||||
public static final String DEFAULT_EXPANSION_SEARCH_MESSAGE = "Select set or expansion";
|
||||
public static final String DEFAULT_EXPANSION_TOOLTIP_MESSAGE = "Fast search set or expansion";
|
||||
|
||||
public static void showFastSearchForStringComboBox(JComboBox combo, String chooseMessage) {
|
||||
showFastSearchForStringComboBox(combo, chooseMessage, 300, 500);
|
||||
|
|
|
|||
|
|
@ -27,8 +27,24 @@ public final class GuiDisplayUtil {
|
|||
|
||||
public static class TextLines {
|
||||
|
||||
public int basicTextLength;
|
||||
public ArrayList<String> lines;
|
||||
private int basicTextLength;
|
||||
private java.util.List<String> lines;
|
||||
|
||||
public int getBasicTextLength() {
|
||||
return basicTextLength;
|
||||
}
|
||||
|
||||
public void setBasicTextLength(int basicTextLength) {
|
||||
this.basicTextLength = basicTextLength;
|
||||
}
|
||||
|
||||
public java.util.List<String> getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
public void setLines(java.util.List<String> lines) {
|
||||
this.lines = lines;
|
||||
}
|
||||
}
|
||||
|
||||
public static void restoreDividerLocations(Rectangle bounds, String lastDividerLocation, JComponent component) {
|
||||
|
|
@ -165,9 +181,9 @@ public final class GuiDisplayUtil {
|
|||
|
||||
public static TextLines getTextLinesfromCardView(CardView card) {
|
||||
TextLines textLines = new TextLines();
|
||||
textLines.lines = new ArrayList<>(card.getRules());
|
||||
textLines.setLines(new ArrayList<>(card.getRules()));
|
||||
for (String rule : card.getRules()) {
|
||||
textLines.basicTextLength += rule.length();
|
||||
textLines.setBasicTextLength(textLines.getBasicTextLength() + rule.length());
|
||||
}
|
||||
if (card.getMageObjectType().canHaveCounters()) {
|
||||
ArrayList<CounterView> counters = new ArrayList<>();
|
||||
|
|
@ -192,15 +208,15 @@ public final class GuiDisplayUtil {
|
|||
index++;
|
||||
}
|
||||
}
|
||||
textLines.lines.add(sb.toString());
|
||||
textLines.basicTextLength += 50;
|
||||
textLines.getLines().add(sb.toString());
|
||||
textLines.setBasicTextLength(textLines.getBasicTextLength() + 50);
|
||||
}
|
||||
}
|
||||
if (card.getMageObjectType().isPermanent() && card instanceof PermanentView) {
|
||||
int damage = ((PermanentView) card).getDamage();
|
||||
if (damage > 0) {
|
||||
textLines.lines.add("<span color='red'><b>Damage dealt:</b> " + damage + "</span>");
|
||||
textLines.basicTextLength += 50;
|
||||
textLines.getLines().add("<span color='red'><b>Damage dealt:</b> " + damage + "</span>");
|
||||
textLines.setBasicTextLength(textLines.getBasicTextLength() + 50);
|
||||
}
|
||||
}
|
||||
return textLines;
|
||||
|
|
@ -350,8 +366,8 @@ public final class GuiDisplayUtil {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!textLines.lines.isEmpty()) {
|
||||
for (String textLine : textLines.lines) {
|
||||
if (!textLines.getLines().isEmpty()) {
|
||||
for (String textLine : textLines.getLines()) {
|
||||
if (textLine != null && !textLine.replace(".", "").trim().isEmpty()) {
|
||||
rule.append("<p style='margin: 2px'>").append(textLine).append("</p>");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,16 +125,16 @@ public abstract class Animation {
|
|||
@Override
|
||||
protected void update(float percentage) {
|
||||
if (tapped) {
|
||||
panel.tappedAngle = CardPanel.TAPPED_ANGLE * percentage;
|
||||
panel.setTappedAngle(CardPanel.TAPPED_ANGLE * percentage);
|
||||
// reverse movement if untapping
|
||||
if (!panel.isTapped()) {
|
||||
panel.tappedAngle = CardPanel.TAPPED_ANGLE - panel.tappedAngle;
|
||||
panel.setTappedAngle(CardPanel.TAPPED_ANGLE - panel.getTappedAngle());
|
||||
}
|
||||
}
|
||||
if (flipped) {
|
||||
panel.flippedAngle = CardPanel.FLIPPED_ANGLE * percentage;
|
||||
panel.setFlippedAngle(CardPanel.FLIPPED_ANGLE * percentage);
|
||||
if (!panel.isFlipped()) {
|
||||
panel.flippedAngle = CardPanel.FLIPPED_ANGLE - panel.flippedAngle;
|
||||
panel.setFlippedAngle(CardPanel.FLIPPED_ANGLE - panel.getFlippedAngle());
|
||||
}
|
||||
}
|
||||
panel.repaint();
|
||||
|
|
@ -143,10 +143,10 @@ public abstract class Animation {
|
|||
@Override
|
||||
protected void end() {
|
||||
if (tapped) {
|
||||
panel.tappedAngle = panel.isTapped() ? CardPanel.TAPPED_ANGLE : 0;
|
||||
panel.setTappedAngle(panel.isTapped() ? CardPanel.TAPPED_ANGLE : 0);
|
||||
}
|
||||
if (flipped) {
|
||||
panel.flippedAngle = panel.isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
|
||||
panel.setFlippedAngle(panel.isFlipped() ? CardPanel.FLIPPED_ANGLE : 0);
|
||||
}
|
||||
parent.onEndAnimation();
|
||||
parent.repaint();
|
||||
|
|
@ -334,7 +334,7 @@ public abstract class Animation {
|
|||
currentX = Math.min(currentX, layeredPane.getWidth() - currentWidth);
|
||||
int currentY = Math.max(0, centerY - Math.round(currentHeight / 2f));
|
||||
currentY = Math.min(currentY, layeredPane.getHeight() - currentHeight);
|
||||
animationPanel.tappedAngle = overPanel.tappedAngle * percentage;
|
||||
animationPanel.setTappedAngle(overPanel.getTappedAngle() * percentage);
|
||||
animationPanel.setCardBounds(currentX, currentY, currentWidth, currentHeight);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,14 +48,14 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
private static final float ROT_CENTER_TO_TOP_CORNER = 1.0295630140987000315797369464196f;
|
||||
private static final float ROT_CENTER_TO_BOTTOM_CORNER = 0.7071067811865475244008443621048f;
|
||||
|
||||
public CardView gameCard;
|
||||
public CardView updateCard;
|
||||
private CardView gameCard;
|
||||
private CardView updateCard;
|
||||
|
||||
// for two faced cards
|
||||
public CardView temporary;
|
||||
private CardView temporary;
|
||||
|
||||
public double tappedAngle = 0;
|
||||
public double flippedAngle = 0;
|
||||
private double tappedAngle = 0;
|
||||
private double flippedAngle = 0;
|
||||
|
||||
private final List<MagePermanent> links = new ArrayList<>();
|
||||
|
||||
|
|
@ -99,14 +99,14 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
|
||||
public CardPanel(CardView newGameCard, UUID gameId, final boolean loadImage, ActionCallback callback, final boolean foil, Dimension dimension) {
|
||||
// Store away params
|
||||
this.gameCard = newGameCard;
|
||||
this.setGameCard(newGameCard);
|
||||
this.callback = callback;
|
||||
this.gameId = gameId;
|
||||
|
||||
// Gather info about the card
|
||||
this.isPermanent = this.gameCard instanceof PermanentView && !this.gameCard.inViewerOnly();
|
||||
this.isPermanent = this.getGameCard() instanceof PermanentView && !this.getGameCard().inViewerOnly();
|
||||
if (isPermanent) {
|
||||
this.hasSickness = ((PermanentView) this.gameCard).hasSummoningSickness();
|
||||
this.hasSickness = ((PermanentView) this.getGameCard()).hasSummoningSickness();
|
||||
}
|
||||
|
||||
// Set to requested size
|
||||
|
|
@ -120,7 +120,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
add(buttonPanel);
|
||||
|
||||
// Both card rendering implementations have a transform button
|
||||
if (this.gameCard.canTransform()) {
|
||||
if (this.getGameCard().canTransform()) {
|
||||
// Create the day night button
|
||||
dayNightButton = new JButton("");
|
||||
dayNightButton.setSize(32, 32);
|
||||
|
|
@ -142,12 +142,12 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
}
|
||||
|
||||
// Both card rendering implementations have a view copy source button
|
||||
if (this.gameCard instanceof PermanentView) {
|
||||
if (this.getGameCard() instanceof PermanentView) {
|
||||
// Create the show source button
|
||||
showCopySourceButton = new JButton("");
|
||||
showCopySourceButton.setSize(32, 32);
|
||||
showCopySourceButton.setToolTipText("This permanent is copying a target. To see original card, push this button or turn mouse wheel down while hovering with the mouse pointer over the permanent.");
|
||||
showCopySourceButton.setVisible(((PermanentView) this.gameCard).isCopy());
|
||||
showCopySourceButton.setVisible(((PermanentView) this.getGameCard()).isCopy());
|
||||
showCopySourceButton.setIcon(new ImageIcon(ImageManagerImpl.instance.getCopyInformIconImage()));
|
||||
showCopySourceButton.addActionListener(e -> {
|
||||
ActionCallback callback1 = Plugins.instance.getActionCallback();
|
||||
|
|
@ -174,8 +174,8 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
tooltipText.setText(getText(cardType, newGameCard));
|
||||
|
||||
// Animation setup
|
||||
tappedAngle = isTapped() ? CardPanel.TAPPED_ANGLE : 0;
|
||||
flippedAngle = isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
|
||||
setTappedAngle(isTapped() ? CardPanel.TAPPED_ANGLE : 0);
|
||||
setFlippedAngle(isFlipped() ? CardPanel.FLIPPED_ANGLE : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -197,7 +197,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
|
||||
public final void initialDraw() {
|
||||
// Kick off
|
||||
if (gameCard.isTransformed()) {
|
||||
if (getGameCard().isTransformed()) {
|
||||
// this calls updateImage
|
||||
toggleTransformed();
|
||||
} else {
|
||||
|
|
@ -325,10 +325,10 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
g2d.translate(edgeOffset * (1 - transformAngle), 0);
|
||||
g2d.scale(transformAngle, 1);
|
||||
}
|
||||
if (tappedAngle + flippedAngle > 0) {
|
||||
if (getTappedAngle() + getFlippedAngle() > 0) {
|
||||
g2d = (Graphics2D) g2d.create();
|
||||
float edgeOffset = cardWidth / 2f;
|
||||
double angle = tappedAngle + (Math.abs(flippedAngle - FLIPPED_ANGLE) < 0.001 ? 0 : flippedAngle);
|
||||
double angle = getTappedAngle() + (Math.abs(getFlippedAngle() - FLIPPED_ANGLE) < 0.001 ? 0 : getFlippedAngle());
|
||||
g2d.rotate(angle, cardXOffset + edgeOffset, cardYOffset + cardHeight - edgeOffset);
|
||||
}
|
||||
super.paint(g2d);
|
||||
|
|
@ -347,7 +347,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return gameCard.toString();
|
||||
return getGameCard().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -433,7 +433,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
}
|
||||
|
||||
public final CardView getCard() {
|
||||
return this.gameCard;
|
||||
return this.getGameCard();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -457,7 +457,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
@Override
|
||||
public final boolean isTapped() {
|
||||
if (isPermanent) {
|
||||
return ((PermanentView) gameCard).isTapped();
|
||||
return ((PermanentView) getGameCard()).isTapped();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -465,7 +465,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
@Override
|
||||
public final boolean isFlipped() {
|
||||
if (isPermanent) {
|
||||
return ((PermanentView) gameCard).isFlipped();
|
||||
return ((PermanentView) getGameCard()).isFlipped();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -473,7 +473,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
@Override
|
||||
public final boolean isTransformed() {
|
||||
if (isPermanent) {
|
||||
if (gameCard.isTransformed()) {
|
||||
if (getGameCard().isTransformed()) {
|
||||
return !this.transformed;
|
||||
} else {
|
||||
return this.transformed;
|
||||
|
|
@ -503,7 +503,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
*/
|
||||
@Override
|
||||
public void update(CardView card) {
|
||||
this.updateCard = card;
|
||||
this.setUpdateCard(card);
|
||||
|
||||
// Animation update
|
||||
if (isPermanent && (card instanceof PermanentView)) {
|
||||
|
|
@ -527,11 +527,11 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
|
||||
// Update art?
|
||||
boolean mustUpdateArt
|
||||
= (!gameCard.getName().equals(card.getName()))
|
||||
|| (gameCard.isFaceDown() != card.isFaceDown());
|
||||
= (!getGameCard().getName().equals(card.getName()))
|
||||
|| (getGameCard().isFaceDown() != card.isFaceDown());
|
||||
|
||||
// Set the new card
|
||||
this.gameCard = card;
|
||||
this.setGameCard(card);
|
||||
|
||||
// Update tooltip text
|
||||
String cardType = getType(card);
|
||||
|
|
@ -580,7 +580,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
|
||||
@Override
|
||||
public CardView getOriginal() {
|
||||
return this.gameCard;
|
||||
return this.getGameCard();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -589,7 +589,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
if (gameCard.hideInfo()) {
|
||||
if (getGameCard().hideInfo()) {
|
||||
return;
|
||||
}
|
||||
if (!tooltipShowing) {
|
||||
|
|
@ -607,22 +607,22 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
data.component = this;
|
||||
data.setComponent(this);
|
||||
callback.mouseDragged(e, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
if (gameCard.hideInfo()) {
|
||||
if (getGameCard().hideInfo()) {
|
||||
return;
|
||||
}
|
||||
data.component = this;
|
||||
data.setComponent(this);
|
||||
callback.mouseMoved(e, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
if (gameCard.hideInfo()) {
|
||||
if (getGameCard().hideInfo()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -630,9 +630,9 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
synchronized (this) {
|
||||
if (tooltipShowing) {
|
||||
tooltipShowing = false;
|
||||
data.component = this;
|
||||
data.card = this.gameCard;
|
||||
data.popupText = tooltipText;
|
||||
data.setComponent(this);
|
||||
data.setCard(this.getGameCard());
|
||||
data.setPopupText(tooltipText);
|
||||
callback.mouseExited(e, data);
|
||||
}
|
||||
}
|
||||
|
|
@ -641,9 +641,9 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
data.component = this;
|
||||
data.card = this.gameCard;
|
||||
data.gameId = this.gameId;
|
||||
data.setComponent(this);
|
||||
data.setCard(this.getGameCard());
|
||||
data.setGameId(this.gameId);
|
||||
callback.mousePressed(e, data);
|
||||
}
|
||||
|
||||
|
|
@ -658,13 +658,13 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
* @return
|
||||
*/
|
||||
private TransferData getTransferDataForMouseEntered() {
|
||||
data.component = this;
|
||||
data.card = this.gameCard;
|
||||
data.popupText = tooltipText;
|
||||
data.gameId = this.gameId;
|
||||
data.locationOnScreen = data.component.getLocationOnScreen(); // we need this for popup
|
||||
data.popupOffsetX = isTapped() ? cardHeight + cardXOffset + POPUP_X_GAP : cardWidth + cardXOffset + POPUP_X_GAP;
|
||||
data.popupOffsetY = 40;
|
||||
data.setComponent(this);
|
||||
data.setCard(this.getGameCard());
|
||||
data.setPopupText(tooltipText);
|
||||
data.setGameId(this.gameId);
|
||||
data.setLocationOnScreen(data.getComponent().getLocationOnScreen()); // we need this for popup
|
||||
data.setPopupOffsetX(isTapped() ? cardHeight + cardXOffset + POPUP_X_GAP : cardWidth + cardXOffset + POPUP_X_GAP);
|
||||
data.setPopupOffsetY(40);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
@ -734,7 +734,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
@Override
|
||||
public PermanentView getOriginalPermanent() {
|
||||
if (isPermanent) {
|
||||
return (PermanentView) this.gameCard;
|
||||
return (PermanentView) this.getGameCard();
|
||||
}
|
||||
throw new IllegalStateException("Is not permanent.");
|
||||
}
|
||||
|
|
@ -757,13 +757,13 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
BufferedImage night = ImageManagerImpl.instance.getNightImage();
|
||||
dayNightButton.setIcon(new ImageIcon(night));
|
||||
}
|
||||
if (this.gameCard.getSecondCardFace() == null) {
|
||||
if (this.getGameCard().getSecondCardFace() == null) {
|
||||
LOGGER.error("no second side for card to transform!");
|
||||
return;
|
||||
}
|
||||
if (!isPermanent) { // use only for custom transformation (when pressing day-night button)
|
||||
this.temporary = this.gameCard;
|
||||
update(this.gameCard.getSecondCardFace());
|
||||
this.setTemporary(this.getGameCard());
|
||||
update(this.getGameCard().getSecondCardFace());
|
||||
}
|
||||
} else {
|
||||
if (dayNightButton != null) { // if transformbable card is copied, button can be null
|
||||
|
|
@ -771,22 +771,22 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
dayNightButton.setIcon(new ImageIcon(day));
|
||||
}
|
||||
if (!isPermanent) { // use only for custom transformation (when pressing day-night button)
|
||||
update(this.temporary);
|
||||
this.temporary = null;
|
||||
update(this.getTemporary());
|
||||
this.setTemporary(null);
|
||||
}
|
||||
}
|
||||
String temp = this.gameCard.getAlternateName();
|
||||
this.gameCard.setAlternateName(this.gameCard.getOriginalName());
|
||||
this.gameCard.setOriginalName(temp);
|
||||
String temp = this.getGameCard().getAlternateName();
|
||||
this.getGameCard().setAlternateName(this.getGameCard().getOriginalName());
|
||||
this.getGameCard().setOriginalName(temp);
|
||||
updateArtImage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
if (gameCard.hideInfo()) {
|
||||
if (getGameCard().hideInfo()) {
|
||||
return;
|
||||
}
|
||||
data.component = this;
|
||||
data.setComponent(this);
|
||||
callback.mouseWheelMoved(e, data);
|
||||
}
|
||||
|
||||
|
|
@ -800,8 +800,8 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
// this update removes the isChoosable mark from targetCardsInLibrary
|
||||
// so only done for permanents because it's needed to redraw counters in different size, if window size was changed
|
||||
// no perfect solution yet (maybe also other not wanted effects for PermanentView objects)
|
||||
if ((updateCard instanceof PermanentView)) {
|
||||
update(updateCard);
|
||||
if ((getUpdateCard() instanceof PermanentView)) {
|
||||
update(getUpdateCard());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -836,4 +836,43 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
this.popupMenu = popupMenu;
|
||||
}
|
||||
|
||||
public CardView getGameCard() {
|
||||
return gameCard;
|
||||
}
|
||||
|
||||
public void setGameCard(CardView gameCard) {
|
||||
this.gameCard = gameCard;
|
||||
}
|
||||
|
||||
public CardView getUpdateCard() {
|
||||
return updateCard;
|
||||
}
|
||||
|
||||
public void setUpdateCard(CardView updateCard) {
|
||||
this.updateCard = updateCard;
|
||||
}
|
||||
|
||||
public CardView getTemporary() {
|
||||
return temporary;
|
||||
}
|
||||
|
||||
public void setTemporary(CardView temporary) {
|
||||
this.temporary = temporary;
|
||||
}
|
||||
|
||||
public double getTappedAngle() {
|
||||
return tappedAngle;
|
||||
}
|
||||
|
||||
public void setTappedAngle(double tappedAngle) {
|
||||
this.tappedAngle = tappedAngle;
|
||||
}
|
||||
|
||||
public double getFlippedAngle() {
|
||||
return flippedAngle;
|
||||
}
|
||||
|
||||
public void setFlippedAngle(double flippedAngle) {
|
||||
this.flippedAngle = flippedAngle;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,6 @@ import org.jdesktop.swingx.graphics.GraphicsUtilities;
|
|||
import org.mage.plugins.card.images.ImageCache;
|
||||
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
|
||||
import mage.cards.action.ActionCallback;
|
||||
import mage.client.constants.Constants;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
|
|
@ -56,12 +52,12 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
private static final int CARD_MAX_SIZE_FOR_ICONS = 200;
|
||||
|
||||
public final ScaledImagePanel imagePanel;
|
||||
public ImagePanel overlayPanel;
|
||||
private ImagePanel overlayPanel;
|
||||
|
||||
public JPanel iconPanel;
|
||||
private JPanel iconPanel;
|
||||
private JButton typeButton;
|
||||
|
||||
public JPanel counterPanel;
|
||||
private JPanel counterPanel;
|
||||
private JLabel loyaltyCounterLabel;
|
||||
private JLabel plusCounterLabel;
|
||||
private JLabel otherCounterLabel;
|
||||
|
|
@ -84,6 +80,30 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
|
||||
private final static SoftValuesLoadingCache<Key, BufferedImage> IMAGE_CACHE;
|
||||
|
||||
public ImagePanel getOverlayPanel() {
|
||||
return overlayPanel;
|
||||
}
|
||||
|
||||
public void setOverlayPanel(ImagePanel overlayPanel) {
|
||||
this.overlayPanel = overlayPanel;
|
||||
}
|
||||
|
||||
public JPanel getIconPanel() {
|
||||
return iconPanel;
|
||||
}
|
||||
|
||||
public void setIconPanel(JPanel iconPanel) {
|
||||
this.iconPanel = iconPanel;
|
||||
}
|
||||
|
||||
public JPanel getCounterPanel() {
|
||||
return counterPanel;
|
||||
}
|
||||
|
||||
public void setCounterPanel(JPanel counterPanel) {
|
||||
this.counterPanel = counterPanel;
|
||||
}
|
||||
|
||||
static class Key {
|
||||
|
||||
final int width;
|
||||
|
|
@ -217,27 +237,27 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
// Counter panel
|
||||
if (!newGameCard.isAbility()) {
|
||||
// panel to show counters on the card
|
||||
counterPanel = new JPanel();
|
||||
counterPanel.setLayout(null);
|
||||
counterPanel.setOpaque(false);
|
||||
add(counterPanel);
|
||||
setCounterPanel(new JPanel());
|
||||
getCounterPanel().setLayout(null);
|
||||
getCounterPanel().setOpaque(false);
|
||||
add(getCounterPanel());
|
||||
|
||||
plusCounterLabel = new JLabel("");
|
||||
plusCounterLabel.setToolTipText("+1/+1");
|
||||
counterPanel.add(plusCounterLabel);
|
||||
getCounterPanel().add(plusCounterLabel);
|
||||
|
||||
minusCounterLabel = new JLabel("");
|
||||
minusCounterLabel.setToolTipText("-1/-1");
|
||||
counterPanel.add(minusCounterLabel);
|
||||
getCounterPanel().add(minusCounterLabel);
|
||||
|
||||
loyaltyCounterLabel = new JLabel("");
|
||||
loyaltyCounterLabel.setToolTipText("loyalty");
|
||||
counterPanel.add(loyaltyCounterLabel);
|
||||
getCounterPanel().add(loyaltyCounterLabel);
|
||||
|
||||
otherCounterLabel = new JLabel("");
|
||||
counterPanel.add(otherCounterLabel);
|
||||
getCounterPanel().add(otherCounterLabel);
|
||||
|
||||
counterPanel.setVisible(false);
|
||||
getCounterPanel().setVisible(false);
|
||||
}
|
||||
|
||||
// Ability icon
|
||||
|
|
@ -250,7 +270,7 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
}
|
||||
|
||||
// Token icon
|
||||
if (this.gameCard.isToken()) {
|
||||
if (this.getGameCard().isToken()) {
|
||||
setTypeIcon(ImageManagerImpl.instance.getTokenIconImage(), "Token Permanent");
|
||||
}
|
||||
|
||||
|
|
@ -259,7 +279,7 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
|
||||
// Title Text
|
||||
titleText = new GlowText();
|
||||
setText(gameCard);
|
||||
setText(getGameCard());
|
||||
// int fontSize = (int) cardHeight / 11;
|
||||
// titleText.setFont(getFont().deriveFont(Font.BOLD, fontSize));
|
||||
titleText.setForeground(Color.white);
|
||||
|
|
@ -275,10 +295,10 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
|
||||
// PT Text
|
||||
ptText = new GlowText();
|
||||
if (gameCard.isCreature()) {
|
||||
ptText.setText(gameCard.getPower() + '/' + gameCard.getToughness());
|
||||
} else if (gameCard.isPlanesWalker()) {
|
||||
ptText.setText(gameCard.getLoyalty());
|
||||
if (getGameCard().isCreature()) {
|
||||
ptText.setText(getGameCard().getPower() + '/' + getGameCard().getToughness());
|
||||
} else if (getGameCard().isPlanesWalker()) {
|
||||
ptText.setText(getGameCard().getLoyalty());
|
||||
}
|
||||
// ptText.setFont(getFont().deriveFont(Font.BOLD, fontSize));
|
||||
ptText.setForeground(Color.white);
|
||||
|
|
@ -287,9 +307,9 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
|
||||
// Sickness overlay
|
||||
BufferedImage sickness = ImageManagerImpl.instance.getSicknessImage();
|
||||
overlayPanel = new ImagePanel(sickness, ImagePanelStyle.SCALED);
|
||||
overlayPanel.setOpaque(false);
|
||||
add(overlayPanel);
|
||||
setOverlayPanel(new ImagePanel(sickness, ImagePanelStyle.SCALED));
|
||||
getOverlayPanel().setOpaque(false);
|
||||
add(getOverlayPanel());
|
||||
|
||||
// Imagel panel
|
||||
imagePanel = new ScaledImagePanel();
|
||||
|
|
@ -305,27 +325,27 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
}
|
||||
|
||||
private void setTypeIcon(BufferedImage bufferedImage, String toolTipText) {
|
||||
iconPanel = new JPanel();
|
||||
iconPanel.setLayout(null);
|
||||
iconPanel.setOpaque(false);
|
||||
add(iconPanel);
|
||||
setIconPanel(new JPanel());
|
||||
getIconPanel().setLayout(null);
|
||||
getIconPanel().setOpaque(false);
|
||||
add(getIconPanel());
|
||||
|
||||
typeButton = new JButton("");
|
||||
typeButton.setLocation(2, 2);
|
||||
typeButton.setSize(25, 25);
|
||||
|
||||
iconPanel.setVisible(true);
|
||||
getIconPanel().setVisible(true);
|
||||
typeButton.setIcon(new ImageIcon(bufferedImage));
|
||||
if (toolTipText != null) {
|
||||
typeButton.setToolTipText(toolTipText);
|
||||
}
|
||||
iconPanel.add(typeButton);
|
||||
getIconPanel().add(typeButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanUp() {
|
||||
super.cleanUp();
|
||||
this.counterPanel = null;
|
||||
this.setCounterPanel(null);
|
||||
}
|
||||
|
||||
private void setText(CardView card) {
|
||||
|
|
@ -386,7 +406,7 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
g2d.drawImage(
|
||||
IMAGE_CACHE.getOrThrow(
|
||||
new Key(getWidth(), getHeight(), getCardWidth(), getCardHeight(), getCardXOffset(), getCardYOffset(),
|
||||
hasImage, isSelected(), isChoosable(), gameCard.isPlayable(), gameCard.isCanAttack())),
|
||||
hasImage, isSelected(), isChoosable(), getGameCard().isPlayable(), getGameCard().isCanAttack())),
|
||||
0, 0, null);
|
||||
g2d.dispose();
|
||||
}
|
||||
|
|
@ -481,7 +501,7 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
|
||||
int symbolMarginX = 2; // 2 px between icons
|
||||
|
||||
String manaCost = ManaSymbols.getStringManaCost(gameCard.getManaCost());
|
||||
String manaCost = ManaSymbols.getStringManaCost(getGameCard().getManaCost());
|
||||
int manaWidth = getManaWidth(manaCost, symbolMarginX);
|
||||
|
||||
// right top corner with margin (sizes from any sample card, length from black border to mana icon)
|
||||
|
|
@ -525,32 +545,32 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
imagePanel.setLocation(realCardSize.x, realCardSize.y);
|
||||
imagePanel.setSize(realCardSize.width, realCardSize.height);
|
||||
|
||||
if (hasSickness() && gameCard.isCreature() && isPermanent()) {
|
||||
overlayPanel.setLocation(realCardSize.x, realCardSize.y);
|
||||
overlayPanel.setSize(realCardSize.width, realCardSize.height);
|
||||
if (hasSickness() && getGameCard().isCreature() && isPermanent()) {
|
||||
getOverlayPanel().setLocation(realCardSize.x, realCardSize.y);
|
||||
getOverlayPanel().setSize(realCardSize.width, realCardSize.height);
|
||||
} else {
|
||||
overlayPanel.setVisible(false);
|
||||
getOverlayPanel().setVisible(false);
|
||||
}
|
||||
|
||||
if (iconPanel != null) {
|
||||
iconPanel.setLocation(realCardSize.x, realCardSize.y);
|
||||
iconPanel.setSize(realCardSize.width, realCardSize.height);
|
||||
if (getIconPanel() != null) {
|
||||
getIconPanel().setLocation(realCardSize.x, realCardSize.y);
|
||||
getIconPanel().setSize(realCardSize.width, realCardSize.height);
|
||||
}
|
||||
if (counterPanel != null) {
|
||||
counterPanel.setLocation(realCardSize.x, realCardSize.y);
|
||||
counterPanel.setSize(realCardSize.width, realCardSize.height);
|
||||
if (getCounterPanel() != null) {
|
||||
getCounterPanel().setLocation(realCardSize.x, realCardSize.y);
|
||||
getCounterPanel().setSize(realCardSize.width, realCardSize.height);
|
||||
int size = cardWidth > WIDTH_LIMIT ? 40 : 20;
|
||||
|
||||
minusCounterLabel.setLocation(counterPanel.getWidth() - size, counterPanel.getHeight() - size * 2);
|
||||
minusCounterLabel.setLocation(getCounterPanel().getWidth() - size, getCounterPanel().getHeight() - size * 2);
|
||||
minusCounterLabel.setSize(size, size);
|
||||
|
||||
plusCounterLabel.setLocation(5, counterPanel.getHeight() - size * 2);
|
||||
plusCounterLabel.setLocation(5, getCounterPanel().getHeight() - size * 2);
|
||||
plusCounterLabel.setSize(size, size);
|
||||
|
||||
loyaltyCounterLabel.setLocation(counterPanel.getWidth() - size, counterPanel.getHeight() - size);
|
||||
loyaltyCounterLabel.setLocation(getCounterPanel().getWidth() - size, getCounterPanel().getHeight() - size);
|
||||
loyaltyCounterLabel.setSize(size, size);
|
||||
|
||||
otherCounterLabel.setLocation(5, counterPanel.getHeight() - size);
|
||||
otherCounterLabel.setLocation(5, getCounterPanel().getHeight() - size);
|
||||
otherCounterLabel.setSize(size, size);
|
||||
|
||||
}
|
||||
|
|
@ -605,7 +625,7 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return gameCard.toString();
|
||||
return getGameCard().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -639,8 +659,8 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
|
||||
@Override
|
||||
public void updateArtImage() {
|
||||
tappedAngle = isTapped() ? CardPanel.TAPPED_ANGLE : 0;
|
||||
flippedAngle = isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
|
||||
setTappedAngle(isTapped() ? CardPanel.TAPPED_ANGLE : 0);
|
||||
setFlippedAngle(isFlipped() ? CardPanel.FLIPPED_ANGLE : 0);
|
||||
|
||||
//final CardView gameCard = this.gameCard;
|
||||
final int stamp = ++updateArtImageStamp;
|
||||
|
|
@ -648,20 +668,20 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
Util.threadPool.submit(() -> {
|
||||
try {
|
||||
final BufferedImage srcImage;
|
||||
if (gameCard.isFaceDown()) {
|
||||
if (getGameCard().isFaceDown()) {
|
||||
srcImage = getFaceDownImage();
|
||||
} else if (getCardWidth() > Constants.THUMBNAIL_SIZE_FULL.width) {
|
||||
srcImage = ImageCache.getImage(gameCard, getCardWidth(), getCardHeight());
|
||||
srcImage = ImageCache.getImage(getGameCard(), getCardWidth(), getCardHeight());
|
||||
} else {
|
||||
srcImage = ImageCache.getThumbnail(gameCard);
|
||||
srcImage = ImageCache.getThumbnail(getGameCard());
|
||||
}
|
||||
if (srcImage == null) {
|
||||
setFullPath(ImageCache.getFilePath(gameCard, getCardWidth()));
|
||||
setFullPath(ImageCache.getFilePath(getGameCard(), getCardWidth()));
|
||||
}
|
||||
UI.invokeLater(() -> {
|
||||
if (stamp == updateArtImageStamp) {
|
||||
hasImage = srcImage != null;
|
||||
setText(gameCard);
|
||||
setText(getGameCard());
|
||||
setImage(srcImage);
|
||||
}
|
||||
});
|
||||
|
|
@ -675,12 +695,12 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
|
||||
private BufferedImage getFaceDownImage() {
|
||||
if (isPermanent()) {
|
||||
if (((PermanentView) gameCard).isMorphed()) {
|
||||
if (((PermanentView) getGameCard()).isMorphed()) {
|
||||
return ImageCache.getMorphImage();
|
||||
} else {
|
||||
return ImageCache.getManifestImage();
|
||||
}
|
||||
} else if (this.gameCard instanceof StackAbilityView) {
|
||||
} else if (this.getGameCard() instanceof StackAbilityView) {
|
||||
return ImageCache.getMorphImage();
|
||||
} else {
|
||||
return ImageCache.getCardbackImage();
|
||||
|
|
@ -690,7 +710,7 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
@Override
|
||||
public void showCardTitle() {
|
||||
displayTitleAnyway = true;
|
||||
setText(gameCard);
|
||||
setText(getGameCard());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -712,13 +732,13 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
|
||||
// Summoning Sickness overlay
|
||||
if (hasSickness() && card.isCreature() && isPermanent()) {
|
||||
overlayPanel.setVisible(true);
|
||||
getOverlayPanel().setVisible(true);
|
||||
} else {
|
||||
overlayPanel.setVisible(false);
|
||||
getOverlayPanel().setVisible(false);
|
||||
}
|
||||
|
||||
// Update counters panel
|
||||
if (counterPanel != null) {
|
||||
if (getCounterPanel() != null) {
|
||||
updateCounters(card);
|
||||
}
|
||||
|
||||
|
|
@ -777,13 +797,13 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
}
|
||||
}
|
||||
|
||||
counterPanel.setVisible(true);
|
||||
getCounterPanel().setVisible(true);
|
||||
} else {
|
||||
plusCounterLabel.setVisible(false);
|
||||
minusCounterLabel.setVisible(false);
|
||||
loyaltyCounterLabel.setVisible(false);
|
||||
otherCounterLabel.setVisible(false);
|
||||
counterPanel.setVisible(false);
|
||||
getCounterPanel().setVisible(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -809,10 +829,10 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
@Override
|
||||
public Image getImage() {
|
||||
if (this.hasImage) {
|
||||
if (gameCard.isFaceDown()) {
|
||||
if (getGameCard().isFaceDown()) {
|
||||
return getFaceDownImage();
|
||||
} else {
|
||||
return ImageCache.getImageOriginal(gameCard);
|
||||
return ImageCache.getImageOriginal(getGameCard());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ public class CardPanelRenderImpl extends CardPanel {
|
|||
super(newGameCard, gameId, loadImage, callback, foil, dimension);
|
||||
|
||||
// Renderer
|
||||
cardRenderer = cardRendererFactory.create(gameCard, isTransformed());
|
||||
cardRenderer = cardRendererFactory.create(getGameCard(), isTransformed());
|
||||
|
||||
// Draw the parts
|
||||
initialDraw();
|
||||
|
|
@ -265,7 +265,7 @@ public class CardPanelRenderImpl extends CardPanel {
|
|||
if (cardImage == null) {
|
||||
// Try to get card image from cache based on our card characteristics
|
||||
ImageKey key
|
||||
= new ImageKey(gameCard, artImage,
|
||||
= new ImageKey(getGameCard(), artImage,
|
||||
getCardWidth(), getCardHeight(),
|
||||
isChoosable(), isSelected());
|
||||
try {
|
||||
|
|
@ -324,8 +324,8 @@ public class CardPanelRenderImpl extends CardPanel {
|
|||
cardRenderer.setFaceArtImage(null);
|
||||
|
||||
// Stop animation
|
||||
tappedAngle = isTapped() ? CardPanel.TAPPED_ANGLE : 0;
|
||||
flippedAngle = isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
|
||||
setTappedAngle(isTapped() ? CardPanel.TAPPED_ANGLE : 0);
|
||||
setFlippedAngle(isFlipped() ? CardPanel.FLIPPED_ANGLE : 0);
|
||||
|
||||
// Schedule a repaint
|
||||
repaint();
|
||||
|
|
@ -340,16 +340,16 @@ public class CardPanelRenderImpl extends CardPanel {
|
|||
try {
|
||||
final BufferedImage srcImage;
|
||||
final BufferedImage faceArtSrcImage;
|
||||
if (gameCard.isFaceDown()) {
|
||||
if (getGameCard().isFaceDown()) {
|
||||
// Nothing to do
|
||||
srcImage = null;
|
||||
faceArtSrcImage = null;
|
||||
} else if (getCardWidth() > Constants.THUMBNAIL_SIZE_FULL.width) {
|
||||
srcImage = ImageCache.getImage(gameCard, getCardWidth(), getCardHeight());
|
||||
faceArtSrcImage = ImageCache.getFaceImage(gameCard, getCardWidth(), getCardHeight());
|
||||
srcImage = ImageCache.getImage(getGameCard(), getCardWidth(), getCardHeight());
|
||||
faceArtSrcImage = ImageCache.getFaceImage(getGameCard(), getCardWidth(), getCardHeight());
|
||||
} else {
|
||||
srcImage = ImageCache.getThumbnail(gameCard);
|
||||
faceArtSrcImage = ImageCache.getFaceImage(gameCard, getCardWidth(), getCardHeight());
|
||||
srcImage = ImageCache.getThumbnail(getGameCard());
|
||||
faceArtSrcImage = ImageCache.getFaceImage(getGameCard(), getCardWidth(), getCardHeight());
|
||||
}
|
||||
|
||||
UI.invokeLater(() -> {
|
||||
|
|
@ -382,7 +382,7 @@ public class CardPanelRenderImpl extends CardPanel {
|
|||
|
||||
// Update renderer
|
||||
cardImage = null;
|
||||
cardRenderer = cardRendererFactory.create(gameCard, isTransformed());
|
||||
cardRenderer = cardRendererFactory.create(getGameCard(), isTransformed());
|
||||
cardRenderer.setArtImage(artImage);
|
||||
cardRenderer.setFaceArtImage(faceArtImage);
|
||||
|
||||
|
|
@ -405,12 +405,12 @@ public class CardPanelRenderImpl extends CardPanel {
|
|||
|
||||
private BufferedImage getFaceDownImage() {
|
||||
if (isPermanent()) {
|
||||
if (((PermanentView) gameCard).isMorphed()) {
|
||||
if (((PermanentView) getGameCard()).isMorphed()) {
|
||||
return ImageCache.getMorphImage();
|
||||
} else {
|
||||
return ImageCache.getManifestImage();
|
||||
}
|
||||
} else if (this.gameCard instanceof StackAbilityView) {
|
||||
} else if (this.getGameCard() instanceof StackAbilityView) {
|
||||
return ImageCache.getMorphImage();
|
||||
} else {
|
||||
return ImageCache.getCardbackImage();
|
||||
|
|
@ -440,10 +440,10 @@ public class CardPanelRenderImpl extends CardPanel {
|
|||
@Override
|
||||
public Image getImage() {
|
||||
if (artImage != null) {
|
||||
if (gameCard.isFaceDown()) {
|
||||
if (getGameCard().isFaceDown()) {
|
||||
return getFaceDownImage();
|
||||
} else {
|
||||
return ImageCache.getImageOriginal(gameCard);
|
||||
return ImageCache.getImageOriginal(getGameCard());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
|
|||
SwingUtilities.invokeLater(() -> {
|
||||
TextLines textLines = GuiDisplayUtil.getTextLinesfromCardView(card);
|
||||
StringBuilder buffer = GuiDisplayUtil.getRulefromCardView(card, textLines);
|
||||
resizeTooltipIfNeeded(container, textLines.basicTextLength, textLines.lines.size());
|
||||
resizeTooltipIfNeeded(container, textLines.getBasicTextLength(), textLines.getLines().size());
|
||||
setText(buffer.toString());
|
||||
setCaretPosition(0);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,19 +9,19 @@ import static mage.constants.Constants.*;
|
|||
*/
|
||||
public class CardDimensions {
|
||||
|
||||
public int frameHeight;
|
||||
public int frameWidth;
|
||||
public int symbolHeight;
|
||||
public int symbolWidth;
|
||||
public int contentXOffset;
|
||||
public int nameYOffset;
|
||||
public int typeYOffset;
|
||||
public int textYOffset;
|
||||
public int textWidth;
|
||||
public int textHeight;
|
||||
public int powBoxTextTop;
|
||||
public int powBoxTextLeft;
|
||||
public int nameFontSize;
|
||||
private final int frameHeight;
|
||||
private final int frameWidth;
|
||||
private final int symbolHeight;
|
||||
private final int symbolWidth;
|
||||
private final int contentXOffset;
|
||||
private final int nameYOffset;
|
||||
private final int typeYOffset;
|
||||
private final int textYOffset;
|
||||
private final int textWidth;
|
||||
private final int textHeight;
|
||||
private final int powBoxTextTop;
|
||||
private final int powBoxTextLeft;
|
||||
private final int nameFontSize;
|
||||
|
||||
public CardDimensions(double scaleFactor) {
|
||||
frameHeight = (int) (FRAME_MAX_HEIGHT * scaleFactor);
|
||||
|
|
@ -39,4 +39,55 @@ public class CardDimensions {
|
|||
nameFontSize = Math.max(9, (int) (NAME_FONT_MAX_SIZE * scaleFactor));
|
||||
}
|
||||
|
||||
public int getFrameHeight() {
|
||||
return frameHeight;
|
||||
}
|
||||
|
||||
public int getFrameWidth() {
|
||||
return frameWidth;
|
||||
}
|
||||
|
||||
public int getSymbolHeight() {
|
||||
return symbolHeight;
|
||||
}
|
||||
|
||||
public int getSymbolWidth() {
|
||||
return symbolWidth;
|
||||
}
|
||||
|
||||
public int getContentXOffset() {
|
||||
return contentXOffset;
|
||||
}
|
||||
|
||||
public int getNameYOffset() {
|
||||
return nameYOffset;
|
||||
}
|
||||
|
||||
public int getTypeYOffset() {
|
||||
return typeYOffset;
|
||||
}
|
||||
|
||||
public int getTextYOffset() {
|
||||
return textYOffset;
|
||||
}
|
||||
|
||||
public int getTextWidth() {
|
||||
return textWidth;
|
||||
}
|
||||
|
||||
public int getTextHeight() {
|
||||
return textHeight;
|
||||
}
|
||||
|
||||
public int getPowBoxTextTop() {
|
||||
return powBoxTextTop;
|
||||
}
|
||||
|
||||
public int getPowBoxTextLeft() {
|
||||
return powBoxTextLeft;
|
||||
}
|
||||
|
||||
public int getNameFontSize() {
|
||||
return nameFontSize;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,67 @@ import mage.cards.TextPopup;
|
|||
import mage.view.CardView;
|
||||
|
||||
public class TransferData {
|
||||
public Component component;
|
||||
public TextPopup popupText;
|
||||
public Point locationOnScreen;
|
||||
public int popupOffsetX;
|
||||
public int popupOffsetY;
|
||||
public UUID gameId;
|
||||
public CardView card;
|
||||
private Component component;
|
||||
private TextPopup popupText;
|
||||
private Point locationOnScreen;
|
||||
private int popupOffsetX;
|
||||
private int popupOffsetY;
|
||||
private UUID gameId;
|
||||
private CardView card;
|
||||
|
||||
public Component getComponent() {
|
||||
return component;
|
||||
}
|
||||
|
||||
public void setComponent(Component component) {
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public TextPopup getPopupText() {
|
||||
return popupText;
|
||||
}
|
||||
|
||||
public void setPopupText(TextPopup popupText) {
|
||||
this.popupText = popupText;
|
||||
}
|
||||
|
||||
public Point getLocationOnScreen() {
|
||||
return locationOnScreen;
|
||||
}
|
||||
|
||||
public void setLocationOnScreen(Point locationOnScreen) {
|
||||
this.locationOnScreen = locationOnScreen;
|
||||
}
|
||||
|
||||
public int getPopupOffsetX() {
|
||||
return popupOffsetX;
|
||||
}
|
||||
|
||||
public void setPopupOffsetX(int popupOffsetX) {
|
||||
this.popupOffsetX = popupOffsetX;
|
||||
}
|
||||
|
||||
public int getPopupOffsetY() {
|
||||
return popupOffsetY;
|
||||
}
|
||||
|
||||
public void setPopupOffsetY(int popupOffsetY) {
|
||||
this.popupOffsetY = popupOffsetY;
|
||||
}
|
||||
|
||||
public UUID getGameId() {
|
||||
return gameId;
|
||||
}
|
||||
|
||||
public void setGameId(UUID gameId) {
|
||||
this.gameId = gameId;
|
||||
}
|
||||
|
||||
public CardView getCard() {
|
||||
return card;
|
||||
}
|
||||
|
||||
public void setCard(CardView card) {
|
||||
this.card = card;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ class ScoutsWarningAsThoughEffect extends AsThoughEffectImpl {
|
|||
|
||||
class ScoutsWarningWatcher extends Watcher {
|
||||
|
||||
public List<String> activeScoutsWarningSpells = new ArrayList<>();
|
||||
private List<String> activeScoutsWarningSpells = new ArrayList<>();
|
||||
|
||||
public ScoutsWarningWatcher() {
|
||||
super(ScoutsWarningWatcher.class.getSimpleName(), WatcherScope.PLAYER);
|
||||
|
|
@ -116,10 +116,10 @@ class ScoutsWarningWatcher extends Watcher {
|
|||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||
if (!activeScoutsWarningSpells.isEmpty() && event.getPlayerId().equals(getControllerId())) {
|
||||
if (!getActiveScoutsWarningSpells().isEmpty() && event.getPlayerId().equals(getControllerId())) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && spell.isCreature()) {
|
||||
activeScoutsWarningSpells.clear();
|
||||
getActiveScoutsWarningSpells().clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -127,18 +127,25 @@ class ScoutsWarningWatcher extends Watcher {
|
|||
|
||||
public void addScoutsWarningSpell(UUID sourceId, int zoneChangeCounter) {
|
||||
String spellKey = sourceId.toString() + '_' + zoneChangeCounter;
|
||||
activeScoutsWarningSpells.add(spellKey);
|
||||
getActiveScoutsWarningSpells().add(spellKey);
|
||||
}
|
||||
|
||||
public boolean isScoutsWarningSpellActive(UUID sourceId, int zoneChangeCounter) {
|
||||
String spellKey = sourceId.toString() + '_' + zoneChangeCounter;
|
||||
return activeScoutsWarningSpells.contains(spellKey);
|
||||
return getActiveScoutsWarningSpells().contains(spellKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
activeScoutsWarningSpells.clear();
|
||||
getActiveScoutsWarningSpells().clear();
|
||||
}
|
||||
|
||||
public List<String> getActiveScoutsWarningSpells() {
|
||||
return activeScoutsWarningSpells;
|
||||
}
|
||||
|
||||
public void setActiveScoutsWarningSpells(List<String> activeScoutsWarningSpells) {
|
||||
this.activeScoutsWarningSpells = activeScoutsWarningSpells;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public final class TemurCharm extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{G}{U}{R}");
|
||||
|
||||
// Choose one -
|
||||
// <strong><EFBFBD></strong> Target creature you control gets +1/+1 until end of turn. That creature fights target creature you don't control.
|
||||
// Target creature you control gets +1/+1 until end of turn. That creature fights target creature you don't control.
|
||||
Effect effect = new BoostTargetEffect(1, 1, Duration.EndOfTurn);
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
effect = new FightTargetsEffect();
|
||||
|
|
@ -51,20 +51,20 @@ public final class TemurCharm extends CardImpl {
|
|||
Target target = new TargetCreaturePermanent(filter);
|
||||
this.getSpellAbility().addTarget(target);
|
||||
|
||||
// <strong><EFBFBD></strong> Counter target spell unless its controller pays {3}.
|
||||
// Counter target spell unless its controller pays {3}.
|
||||
Mode mode = new Mode();
|
||||
mode.addEffect(new CounterUnlessPaysEffect(new GenericManaCost(3)));
|
||||
mode.addTarget(new TargetSpell());
|
||||
this.getSpellAbility().addMode(mode);
|
||||
|
||||
// <strong><EFBFBD></strong> Creatures with power 3 or less can't block this turn.
|
||||
// Creatures with power 3 or less can't block this turn.
|
||||
mode = new Mode();
|
||||
mode.addEffect(new CantBlockAllEffect(filterCantBlock, Duration.EndOfTurn));
|
||||
this.getSpellAbility().addMode(mode);
|
||||
|
||||
}
|
||||
|
||||
public TemurCharm(final TemurCharm card) {
|
||||
private TemurCharm(final TemurCharm card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -615,7 +615,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
}
|
||||
|
||||
List<ExpansionSet.SetCardInfo> cardInfo = Sets.findSet(expansionSetCode).findCardInfoByClass(secondSideCardClazz);
|
||||
assert cardInfo.size() == 1; // should find 1 second side card
|
||||
if (cardInfo.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,9 +174,7 @@ public class StackAbility extends StackObjImpl implements Ability {
|
|||
|
||||
@Override
|
||||
public Abilities<Ability> getAbilities() {
|
||||
Abilities<Ability> abilities = new AbilitiesImpl<>();
|
||||
abilities.add(ability);
|
||||
return abilities;
|
||||
return new AbilitiesImpl<>(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import mage.game.tournament.TournamentPlayer;
|
|||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Quercitron
|
||||
*/
|
||||
|
||||
|
|
@ -23,7 +22,7 @@ public class SwissPairingMinimalWeightMatching {
|
|||
|
||||
private final int playersCount;
|
||||
|
||||
List<PlayerInfo> swissPlayers;
|
||||
private List<PlayerInfo> swissPlayers;
|
||||
|
||||
// number of vertexes in graph
|
||||
private final int n;
|
||||
|
|
@ -37,8 +36,8 @@ public class SwissPairingMinimalWeightMatching {
|
|||
swissPlayers = new ArrayList<>();
|
||||
for (TournamentPlayer tournamentPlayer : players) {
|
||||
PlayerInfo swissPlayer = new PlayerInfo();
|
||||
swissPlayer.tournamentPlayer = tournamentPlayer;
|
||||
swissPlayer.points = tournamentPlayer.getPoints();
|
||||
swissPlayer.setTournamentPlayer(tournamentPlayer);
|
||||
swissPlayer.setPoints(tournamentPlayer.getPoints());
|
||||
swissPlayers.add(swissPlayer);
|
||||
}
|
||||
|
||||
|
|
@ -46,8 +45,8 @@ public class SwissPairingMinimalWeightMatching {
|
|||
Collections.shuffle(swissPlayers);
|
||||
Map<TournamentPlayer, Integer> map = new HashMap<>();
|
||||
for (int i = 0; i < playersCount; i++) {
|
||||
swissPlayers.get(i).id = i;
|
||||
map.put(swissPlayers.get(i).tournamentPlayer, i);
|
||||
swissPlayers.get(i).setId(i);
|
||||
map.put(swissPlayers.get(i).getTournamentPlayer(), i);
|
||||
}
|
||||
|
||||
// calculate Tie Breaker points -- Sum of Opponents' Scores (SOS)
|
||||
|
|
@ -62,10 +61,10 @@ public class SwissPairingMinimalWeightMatching {
|
|||
|
||||
// a player could have left the tournament, so we should check if id is not null
|
||||
if (id1 != null) {
|
||||
swissPlayers.get(id1).sosPoints += player2.getPoints();
|
||||
swissPlayers.get(id1).setSosPoints(swissPlayers.get(id1).getSosPoints() + player2.getPoints());
|
||||
}
|
||||
if (id2 != null) {
|
||||
swissPlayers.get(id2).sosPoints += player1.getPoints();
|
||||
swissPlayers.get(id2).setSosPoints(swissPlayers.get(id2).getSosPoints() + player1.getPoints());
|
||||
}
|
||||
// todo: sos points for byes? maybe add player points?
|
||||
}
|
||||
|
|
@ -73,18 +72,18 @@ public class SwissPairingMinimalWeightMatching {
|
|||
|
||||
// sort by points and then by sos points
|
||||
swissPlayers.sort((p1, p2) -> {
|
||||
int result = p2.points - p1.points;
|
||||
int result = p2.getPoints() - p1.getPoints();
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
return p2.sosPoints - p1.sosPoints;
|
||||
return p2.getSosPoints() - p1.getSosPoints();
|
||||
});
|
||||
|
||||
// order could be changed, update ids and mapping
|
||||
map.clear();
|
||||
for (int i = 0; i < playersCount; i++) {
|
||||
swissPlayers.get(i).id = i;
|
||||
map.put(swissPlayers.get(i).tournamentPlayer, i);
|
||||
swissPlayers.get(i).setId(i);
|
||||
map.put(swissPlayers.get(i).getTournamentPlayer(), i);
|
||||
}
|
||||
|
||||
// count ties and matches between players
|
||||
|
|
@ -125,18 +124,18 @@ public class SwissPairingMinimalWeightMatching {
|
|||
for (int i = 0; i < playersCount; i++) {
|
||||
for (int j = 0; j < i; j++) {
|
||||
w[i][j] = Math.abs(i - j) +
|
||||
pointsDiffMultiplier * Math.abs(swissPlayers.get(i).points - swissPlayers.get(j).points);
|
||||
pointsDiffMultiplier * Math.abs(swissPlayers.get(i).getPoints() - swissPlayers.get(j).getPoints());
|
||||
w[j][i] = w[i][j];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < playersCount; i++) {
|
||||
PlayerInfo player = swissPlayers.get(i);
|
||||
for (int p = player.points; p >= 0; p--) {
|
||||
for (int p = player.getPoints(); p >= 0; p--) {
|
||||
int first = -1;
|
||||
int last = -1;
|
||||
for (int j = 0; j < playersCount; j++) {
|
||||
if (swissPlayers.get(j).points == p) {
|
||||
if (swissPlayers.get(j).getPoints() == p) {
|
||||
if (first < 0) {
|
||||
first = j;
|
||||
}
|
||||
|
|
@ -146,8 +145,8 @@ public class SwissPairingMinimalWeightMatching {
|
|||
if (first < 0) {
|
||||
continue;
|
||||
}
|
||||
int self = (p == player.points ? i : first - 1);
|
||||
int diff = pointsDiffMultiplier * (player.points - p);
|
||||
int self = (p == player.getPoints() ? i : first - 1);
|
||||
int diff = pointsDiffMultiplier * (player.getPoints() - p);
|
||||
for (int j = Math.max(first, i); j <= last; j++) {
|
||||
w[i][j] = Math.abs(j - (last + first - self)) + diff;
|
||||
w[j][i] = w[i][j];
|
||||
|
|
@ -168,7 +167,7 @@ public class SwissPairingMinimalWeightMatching {
|
|||
// try to avoid giving the same person multiple byes
|
||||
if (n > playersCount) {
|
||||
for (int i = 0; i < playersCount; i++) {
|
||||
w[i][n - 1] = 10 * (swissPlayers.get(i).points - swissPlayers.get(playersCount - 1).points) + (playersCount - i - 1);
|
||||
w[i][n - 1] = 10 * (swissPlayers.get(i).getPoints() - swissPlayers.get(playersCount - 1).getPoints()) + (playersCount - i - 1);
|
||||
w[i][n - 1] += byes[i] * 2000;
|
||||
w[n - 1][i] = w[i][n - 1];
|
||||
}
|
||||
|
|
@ -195,9 +194,9 @@ public class SwissPairingMinimalWeightMatching {
|
|||
List<TournamentPairing> pairings = new ArrayList<>();
|
||||
List<TournamentPlayer> playerByes = new ArrayList<>();
|
||||
|
||||
Map<Integer, TournamentPlayer> map = new HashMap<>();
|
||||
Map<Integer, TournamentPlayer> map = new HashMap<>();
|
||||
for (PlayerInfo player : swissPlayers) {
|
||||
map.put(player.id, player.tournamentPlayer);
|
||||
map.put(player.getId(), player.getTournamentPlayer());
|
||||
}
|
||||
|
||||
if (n > playersCount) {
|
||||
|
|
@ -218,15 +217,15 @@ public class SwissPairingMinimalWeightMatching {
|
|||
return new RoundPairings(pairings, playerByes);
|
||||
}
|
||||
|
||||
boolean[] used;
|
||||
private boolean[] used;
|
||||
|
||||
// current pairs
|
||||
int[] pairs;
|
||||
private int[] pairs;
|
||||
// current weight
|
||||
int weight;
|
||||
private int weight;
|
||||
|
||||
int[] result;
|
||||
int minCost;
|
||||
private int[] result;
|
||||
private int minCost;
|
||||
|
||||
// backtrack all possible pairings and choose one with minimal weight
|
||||
private void makePairings(int t) {
|
||||
|
|
@ -262,13 +261,45 @@ public class SwissPairingMinimalWeightMatching {
|
|||
}
|
||||
|
||||
static class PlayerInfo {
|
||||
public int id;
|
||||
private int id;
|
||||
|
||||
public TournamentPlayer tournamentPlayer;
|
||||
private TournamentPlayer tournamentPlayer;
|
||||
|
||||
public int points;
|
||||
private int points;
|
||||
|
||||
public int sosPoints;
|
||||
private int sosPoints;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public TournamentPlayer getTournamentPlayer() {
|
||||
return tournamentPlayer;
|
||||
}
|
||||
|
||||
public void setTournamentPlayer(TournamentPlayer tournamentPlayer) {
|
||||
this.tournamentPlayer = tournamentPlayer;
|
||||
}
|
||||
|
||||
public int getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
public void setPoints(int points) {
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
public int getSosPoints() {
|
||||
return sosPoints;
|
||||
}
|
||||
|
||||
public void setSosPoints(int sosPoints) {
|
||||
this.sosPoints = sosPoints;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue