Search in sources :

Example 1 with CardIconRenderSettings

use of mage.abilities.icon.CardIconRenderSettings in project mage by magefree.

the class DraftGrid method loadBooster.

public void loadBooster(CardsView booster, BigCard bigCard) {
    if (booster != null && booster.isEmpty()) {
        emptyGrid = true;
    } else {
        if (!emptyGrid) {
            AudioManager.playOnDraftSelect();
        }
        emptyGrid = false;
    }
    this.bigCard = bigCard;
    this.removeAll();
    int maxRows = 4;
    int numColumns = 5;
    int curColumn = 0;
    int curRow = 0;
    int offsetX = 5;
    int offsetY = 3;
    CardDimensions cardDimension = null;
    int maxCards;
    double scale;
    for (int i = 1; i < maxRows; i++) {
        scale = (double) (this.getHeight() / i) / Constants.FRAME_MAX_HEIGHT;
        cardDimension = new CardDimensions(scale);
        maxCards = this.getWidth() / (cardDimension.getFrameWidth() + offsetX);
        if ((maxCards * i) >= booster.size()) {
            numColumns = booster.size() / i;
            if (booster.size() % i > 0) {
                numColumns++;
            }
            break;
        }
    }
    if (cardDimension != null) {
        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());
        for (CardView card : sortedCards) {
            MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, new CardIconRenderSettings(), dimension, null, true, true, PreferencesDialog.getRenderMode(), true);
            cardImg.setCardContainerRef(this);
            cardImg.update(card);
            this.add(cardImg);
            rectangle.setLocation(curColumn * (cardDimension.getFrameWidth() + offsetX) + offsetX, curRow * (rectangle.height + offsetY) + offsetY);
            cardImg.setCardBounds(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
            curColumn++;
            if (curColumn == numColumns) {
                curColumn = 0;
                curRow++;
            }
        }
        repaint();
    } else {
        logger.warn("Draft Grid - no possible fit of cards");
    }
}
Also used : CardViewRarityComparator(mage.client.util.comparators.CardViewRarityComparator) CardView(mage.view.CardView) ArrayList(java.util.ArrayList) CardDimensions(mage.cards.CardDimensions) MageCard(mage.cards.MageCard) CardIconRenderSettings(mage.abilities.icon.CardIconRenderSettings)

Example 2 with CardIconRenderSettings

use of mage.abilities.icon.CardIconRenderSettings in project mage by magefree.

the class CardsList method addCard.

private MageCard addCard(CardView card, BigCard bigCard, UUID gameId) {
    MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, new CardIconRenderSettings(), cardDimension, gameId, true, true, PreferencesDialog.getRenderMode(), true);
    cardImg.setCardContainerRef(this);
    cardImg.update(card);
    // card position calculated on parent call by drawCards
    // cardImg.setCardBounds(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
    // count label must be on layer 0 for background drawing
    cardArea.add(cardImg, (Integer) 10);
    return cardImg;
}
Also used : MageCard(mage.cards.MageCard) CardIconRenderSettings(mage.abilities.icon.CardIconRenderSettings)

Example 3 with CardIconRenderSettings

use of mage.abilities.icon.CardIconRenderSettings in project mage by magefree.

the class CardPanelTypeComparator method addCard.

private void addCard(CardView card, BigCard bigCard, UUID gameId, boolean drawImage) {
    MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, new CardIconRenderSettings(), cardDimension, gameId, drawImage, true, PreferencesDialog.getRenderMode(), true);
    cardImg.setCardContainerRef(this);
    cardImg.update(card);
    // card position calculated on parent call by drawCards
    // cardImg.setCardBounds(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
    cards.put(card.getId(), cardImg);
    // count label must be on layer 0 for background drawing
    this.add(cardImg, (Integer) 10);
}
Also used : MageCard(mage.cards.MageCard) CardIconRenderSettings(mage.abilities.icon.CardIconRenderSettings)

Example 4 with CardIconRenderSettings

use of mage.abilities.icon.CardIconRenderSettings in project mage by magefree.

the class MageBook method addCard.

private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle, boolean asCard) {
    if (cardDimension == null) {
        cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
    }
    final MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, new CardIconRenderSettings(), cardDimension, gameId, true, true, PreferencesDialog.getRenderMode(), true);
    cardImg.setCardContainerRef(jLayeredPane);
    cardImg.update(card);
    cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.getFrameWidth(), cardDimensions.getFrameHeight());
    jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
    // card caption must be below real card caption to see full name even with mana icons
    cardImg.setCardCaptionTopOffset(CARD_CAPTION_OFFSET_Y);
    if (asCard) {
        // card number label
        JLabel cardNumber = new JLabel();
        // image panel have empty space in bottom (bug?), need to move label up
        int dy = -5;
        cardNumber.setBounds(rectangle.x, rectangle.y + cardImg.getCardLocation().getCardHeight() + dy, cardDimensions.getFrameWidth(), 20);
        cardNumber.setHorizontalAlignment(SwingConstants.CENTER);
        cardNumber.setFont(jLayeredPane.getFont().deriveFont(jLayeredPane.getFont().getStyle() | Font.BOLD));
        cardNumber.setText(card.getCardNumber());
        jLayeredPane.add(cardNumber);
        // draft rating label
        JLabel draftRating = new JLabel();
        // under card number
        dy = -5 * 2 + cardNumber.getHeight();
        draftRating.setBounds(rectangle.x, rectangle.y + cardImg.getCardLocation().getCardHeight() + dy, cardDimensions.getFrameWidth(), 20);
        draftRating.setHorizontalAlignment(SwingConstants.CENTER);
        draftRating.setFont(jLayeredPane.getFont().deriveFont(jLayeredPane.getFont().getStyle() | Font.BOLD));
        if (card.getOriginalCard() != null) {
            draftRating.setText("draft rating: " + RateCard.rateCard(card.getOriginalCard(), null));
        } else {
            draftRating.setText("");
        }
        jLayeredPane.add(draftRating);
    }
}
Also used : MageCard(mage.cards.MageCard) CardIconRenderSettings(mage.abilities.icon.CardIconRenderSettings)

Example 5 with CardIconRenderSettings

use of mage.abilities.icon.CardIconRenderSettings in project mage by magefree.

the class MageBook method addToken.

private void addToken(Token token, BigCard bigCard, UUID gameId, Rectangle rectangle) {
    if (cardDimension == null) {
        cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
    }
    PermanentToken newToken = new PermanentToken(token, null, token.getOriginalExpansionSetCode(), null);
    newToken.removeSummoningSickness();
    PermanentView theToken = new PermanentView(newToken, null, null, null);
    theToken.setInViewerOnly(true);
    final MageCard cardImg = Plugins.instance.getMagePermanent(theToken, bigCard, new CardIconRenderSettings(), cardDimension, gameId, true, PreferencesDialog.getRenderMode(), true);
    cardImg.setCardContainerRef(jLayeredPane);
    jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
    cardImg.update(theToken);
    cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.getFrameWidth(), cardDimensions.getFrameHeight());
}
Also used : PermanentToken(mage.game.permanent.PermanentToken) MageCard(mage.cards.MageCard) CardIconRenderSettings(mage.abilities.icon.CardIconRenderSettings)

Aggregations

CardIconRenderSettings (mage.abilities.icon.CardIconRenderSettings)10 MageCard (mage.cards.MageCard)10 ArrayList (java.util.ArrayList)2 CardView (mage.view.CardView)2 CardDimensions (mage.cards.CardDimensions)1 CardViewRarityComparator (mage.client.util.comparators.CardViewRarityComparator)1 PermanentToken (mage.game.permanent.PermanentToken)1