use of mage.view.CardsView in project mage by magefree.
the class CardSelector method filterCards.
private void filterCards() {
FilterCard filter = buildFilter();
MageFrame.getDesktop().setCursor(new Cursor(Cursor.WAIT_CURSOR));
try {
// debug
// debugObjectMemorySize("Old cards size", this.currentView.getCardsStore());
this.currentView.clearCardsStoreBeforeUpdate();
java.util.List<Card> filteredCards = new ArrayList<>();
if (chkPennyDreadful.isSelected() && pdAllowed.isEmpty()) {
pdAllowed.putAll(PennyDreadfulLegalityUtil.getLegalCardList());
}
if (limited) {
for (Card card : cards) {
if (filter.match(card, null)) {
filteredCards.add(card);
}
}
} else {
java.util.List<CardInfo> foundCards = CardRepository.instance.findCards(buildCriteria());
for (CardInfo cardInfo : foundCards) {
// filter by penny
if (chkPennyDreadful.isSelected()) {
if (!pdAllowed.containsKey(cardInfo.getName())) {
continue;
}
}
// filter by settings
Card card = cardInfo.getMockCard();
if (!filter.match(card, null)) {
continue;
}
// found
filteredCards.add(card);
}
}
// force to list mode on too much cards
if (currentView instanceof CardGrid && filteredCards.size() > CardGrid.MAX_IMAGES) {
this.toggleViewMode();
}
// debug
// debugObjectMemorySize("New cards size", filteredCards);
this.currentView.loadCards(new CardsView(filteredCards), sortSetting, bigCard, null, false);
this.cardCount.setText(String.valueOf(filteredCards.size()));
} finally {
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}
use of mage.view.CardsView in project mage by magefree.
the class ArrowUtil method drawArrowsForTargets.
public static void drawArrowsForTargets(TransferData data, Point parentPoint) {
java.util.List<UUID> targets = data.getCard().getTargets();
if (targets == null) {
return;
}
Point me = new Point(data.getLocationOnScreen());
me.translate(-parentPoint.x, -parentPoint.y);
for (UUID uuid : targets) {
PlayAreaPanel p = MageFrame.getGamePlayers(data.getGameId()).get(uuid);
if (p != null) {
Point target = p.getLocationOnScreen();
target.translate(-parentPoint.x, -parentPoint.y);
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.getGamePlayers(data.getGameId()).values()) {
MageCard permanent = panel.getBattlefieldPanel().getPermanentPanels().get(uuid);
if (permanent != null) {
Point target = permanent.getCardLocationOnScreen().getCardPoint();
target.translate(-parentPoint.x, -parentPoint.y);
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;
}
PlayerView view = panel.getPlayerPanel().getPlayer();
if (view != null) {
CardsView graveyard = view.getGraveyard();
if (graveyard.containsKey(uuid)) {
p = MageFrame.getGamePlayers(data.getGameId()).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.getGameId(), (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 15, (int) target.getY() + 145 - yOffset, Color.red, ArrowBuilder.Type.TARGET);
}
}
}
}
}
}
use of mage.view.CardsView in project mage by magefree.
the class DeckArea method loadDeck.
public void loadDeck(Deck deck, boolean useLayout, BigCard bigCard) {
lastDeck = deck;
lastBigCard = bigCard;
deckList.setCards(new CardsView(filterHidden(lastDeck.getCards())), useLayout ? deck.getCardsLayout() : null, lastBigCard);
if (sideboardList.isVisible()) {
sideboardList.setCards(new CardsView(filterHidden(lastDeck.getSideboard())), useLayout ? deck.getSideboardLayout() : null, lastBigCard);
}
}
Aggregations