Search in sources :

Example 1 with MageCardSpace

use of mage.cards.MageCardSpace in project mage by magefree.

the class MageLayer method setCardBounds.

@Override
public void setCardBounds(int x, int y, int width, int height) {
    // if (this.getTopPanelRef() == this && this.getOriginal().getName().equals("Kathari Remnant")) { // for debug only
    if (this.getTopPanelRef() == this) {
        // TODO: is it support multi layer drawing?
        // scale inner card and create space for additional drawing like icons
        MageCardSpace innerSpace = getAdditionalSpaces(width, height);
        // extra space for animation and other drawing
        // WTF, I'm tired with render calcs, so make BIG draw spaces for any needs
        MageCardSpace outerSpace = new MageCardSpace(width * 2, width * 2, height * 2, height * 2);
        // MageCardSpace outerSpace = new MageCardSpace(50, 30, 150, 20);
        this.lastOuterSpace = outerSpace;
        // construct new spaces (outer + inner)
        MageCardSpace fullSpace = MageCardSpace.combine(innerSpace, outerSpace).withDebugColor(innerSpace.getDebugColor());
        this.setEmptySpaces(fullSpace);
        // noinspection deprecation - it's ok to use inner setBounds here
        this.setBounds(x - outerSpace.getLeft(), y - outerSpace.getTop(), width + outerSpace.getWidth(), height + outerSpace.getHeight());
        mainPanel.setCardBounds(x + innerSpace.getLeft(), y + innerSpace.getTop(), width - innerSpace.getWidth(), height - innerSpace.getHeight());
    } else {
        this.setEmptySpaces(0, 0, 0, 0);
        // noinspection deprecation - it's ok to use inner setBounds here
        this.setBounds(x, y, width, height);
        mainPanel.setCardBounds(x, y, width, height);
    }
    MageCardLocation location = this.getCardLocation();
    // panel sizes
    this.mainLayerCard.setBounds(0, 0, location.getComponentWidth(), location.getComponentHeight());
    this.mainLayerIcons.setBounds(0, 0, location.getComponentWidth(), location.getComponentHeight());
    // icons sizes
    Rectangle cardSize = new Rectangle(location.getCardRelativeX(), location.getCardRelativeY(), location.getCardWidth(), location.getCardHeight());
    iconsPanels.forEach(panel -> {
        panel.updateSizes(cardSize);
    });
}
Also used : MageCardSpace(mage.cards.MageCardSpace) MageCardLocation(mage.cards.MageCardLocation)

Aggregations

MageCardLocation (mage.cards.MageCardLocation)1 MageCardSpace (mage.cards.MageCardSpace)1