use of mage.abilities.icon.CardIconRenderSettings in project mage by magefree.
the class SelectionBox method addCardView.
public void addCardView(final CardView card, boolean duplicated) {
allCards.add(card);
// Update counts
for (CardTypeCounter counter : allCounters) {
counter.add(card);
}
updateCounts();
// Create the card view
final MageCard cardPanel = Plugins.instance.getMageCard(card, lastBigCard, new CardIconRenderSettings(), new Dimension(getCardWidth(), getCardHeight()), null, true, true, PreferencesDialog.getRenderMode(), true);
cardPanel.setCardContainerRef(this);
cardPanel.update(card);
// cards bounds set in layoutGrid()
cardPanel.setCardCaptionTopOffset(0);
// ENABLE DRAG SUPPORT FOR CARDS
// TODO: rewrite mouseDragged in MageActionCallback, so it can support any drags, not hands only
cardPanel.addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseDragged(MouseEvent e) {
if (!dragger.isDragging()) {
// If the card isn't already selected, make sure it is
if (!card.isSelected()) {
selectCard(card);
}
dragger.handleDragStart(cardPanel, e);
}
}
});
// And add it
cardContent.add(cardPanel);
cardViews.put(card.getId(), cardPanel);
if (duplicated) {
sortIntoGrid(card);
eventSource.fireEvent(card, ClientEventType.DECK_ADD_SPECIFIC_CARD);
// clear grid from empty rows
trimGrid();
// Update layout
layoutGrid();
repaintGrid();
}
}
use of mage.abilities.icon.CardIconRenderSettings in project mage by magefree.
the class Cards method addCard.
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
MageCard mageCard = Plugins.instance.getMageCard(card, bigCard, new CardIconRenderSettings(), getCardDimension(), gameId, true, true, PreferencesDialog.getRenderMode(), true);
mageCard.setCardContainerRef(cardArea);
mageCard.update(card);
if (zone != null) {
mageCard.setZone(zone);
}
cards.put(card.getId(), mageCard);
cardArea.add(mageCard);
definePosition(mageCard);
}
use of mage.abilities.icon.CardIconRenderSettings in project mage by magefree.
the class CardArea method addCard.
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
if (card instanceof AbilityView) {
CardView tmp = ((AbilityView) card).getSourceCard();
tmp.overrideRules(card.getRules());
tmp.setIsAbility(true);
tmp.overrideTargets(card.getTargets());
// cross-reference, required for ability picker
tmp.setAbility(card);
card = tmp;
}
CardIconRenderSettings currentIconsRender;
if (this.customRenderMode >= 0) {
// debug
currentIconsRender = new CardIconRenderSettings().withDebugMode(true).withCustomPosition(customCardIconPosition).withCustomOrder(customCardIconOrder).withCustomColor(customCardIconColor).withCustomMaxVisibleCount(customCardIconsMaxVisibleCount).withCustomIconSizePercent(30);
} else {
// default
currentIconsRender = new CardIconRenderSettings();
}
MageCard cardPanel = Plugins.instance.getMageCard(card, bigCard, currentIconsRender, cardDimension, gameId, true, true, customRenderMode != -1 ? customRenderMode : PreferencesDialog.getRenderMode(), customNeedFullPermanentRender);
cardPanel.setCardContainerRef(this);
cardPanel.update(card);
cardPanel.setCardBounds(rectangle.x, rectangle.y, cardDimension.width, cardDimension.height);
cardArea.add(cardPanel);
cardArea.moveToFront(cardPanel);
// new card have same settings as current view
cardPanel.setCardCaptionTopOffset(yCardCaptionOffsetPercent);
cardPanel.showCardTitle();
}
use of mage.abilities.icon.CardIconRenderSettings in project mage by magefree.
the class ChoiceDialog method displayCards.
private void displayCards(CardsView cards, UUID gameId, BigCard bigCard) {
if (cards.isEmpty()) {
return;
}
java.util.List<Component> toRemove = new ArrayList<>();
for (int i = getComponentCount() - 1; i > 0; i--) {
Component o = getComponent(i);
if (o instanceof MageCard) {
toRemove.add(o);
}
}
for (Component aToRemove : toRemove) {
remove(aToRemove);
}
java.util.List<CardView> cardList = new ArrayList<>(cards.values());
int width = SettingsManager.instance.getCardSize().width;
int height = SettingsManager.instance.getCardSize().height;
int dx = 0;
int dy = 30;
int startIndex = (page - 1) * (in_a_row * rows);
int countPerPage = (in_a_row * rows);
int j = 0;
for (int i = startIndex; i < cards.size() && i < startIndex + countPerPage; i++) {
if (i > startIndex && i % in_a_row == 0) {
// next row
j++;
dx = 0;
}
CardView card = cardList.get(i);
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, new CardIconRenderSettings(), getCardDimension(), gameId, true, true, PreferencesDialog.getRenderMode(), true);
cardImg.setCardContainerRef(this);
cardImg.update(card);
cardImg.setCardBounds(dx, dy + j * (height + 30), width, height);
this.add(cardImg);
dx += (width + 20);
}
repaint();
}
use of mage.abilities.icon.CardIconRenderSettings in project mage by magefree.
the class BattlefieldPanel method addPermanent.
private void addPermanent(PermanentView permanent, final int count) {
if (cardDimension == null) {
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
}
final MageCard perm = Plugins.instance.getMagePermanent(permanent, bigCard, new CardIconRenderSettings(), cardDimension, gameId, true, PreferencesDialog.getRenderMode(), true);
perm.setCardContainerRef(jPanel);
perm.update(permanent);
// cards sizes changes in parent call by sortLayout
// perm.setCardBounds
permanents.put(permanent.getId(), perm);
this.jPanel.add(perm, (Integer) 10);
moveToFront(jPanel);
Plugins.instance.onAddCard(perm, 1);
if (permanent.isArtifact()) {
addedArtifact = true;
} else if (permanent.isCreature()) {
addedCreature = true;
} else {
addedPermanent = true;
}
}
Aggregations