mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
sort cards in deck editor by name
This commit is contained in:
parent
499a6fb0df
commit
41bf33d107
3 changed files with 25 additions and 5 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.1" encoding="UTF-8" ?>
|
||||||
|
|
||||||
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||||
<Properties>
|
<Properties>
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,10 @@ import java.awt.Rectangle;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.beans.Beans;
|
import java.beans.Beans;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
|
|
@ -66,12 +70,19 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
|
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
|
||||||
|
loadCards(showCards, bigCard, gameId, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId, boolean sorted) {
|
||||||
//FIXME: why we remove all cards? for performance it's better to merge changes
|
//FIXME: why we remove all cards? for performance it's better to merge changes
|
||||||
cardArea.removeAll();
|
cardArea.removeAll();
|
||||||
if (showCards != null && showCards.size() > 0) {
|
if (showCards != null && showCards.size() > 0) {
|
||||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (CardView card: showCards.values()) {
|
List<CardView> sortedCards = new ArrayList<CardView>(showCards.values());
|
||||||
|
if (sorted)
|
||||||
|
Collections.sort(sortedCards, new CardViewComparator());
|
||||||
|
for (CardView card: sortedCards) {
|
||||||
addCard(card, bigCard, gameId, rectangle);
|
addCard(card, bigCard, gameId, rectangle);
|
||||||
if (count >= 10) {
|
if (count >= 10) {
|
||||||
rectangle.translate(Config.dimensions.frameWidth, -200);
|
rectangle.translate(Config.dimensions.frameWidth, -200);
|
||||||
|
|
@ -164,3 +175,12 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CardViewComparator implements Comparator<CardView> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(CardView o1, CardView o2) {
|
||||||
|
return o1.getName().compareTo(o2.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -37,7 +37,7 @@ package mage.client.deckeditor;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.deckeditor.collection.viewer.Huerotator2;
|
//import mage.client.deckeditor.collection.viewer.Huerotator2;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.Event;
|
import mage.client.util.Event;
|
||||||
import mage.client.util.Listener;
|
import mage.client.util.Listener;
|
||||||
|
|
@ -149,8 +149,8 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
try {
|
try {
|
||||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||||
this.txtDeckName.setText(deck.getName());
|
this.txtDeckName.setText(deck.getName());
|
||||||
deckArea.getDeckList().loadCards(new CardsView(deck.getCards()), bigCard, null);
|
deckArea.getDeckList().loadCards(new CardsView(deck.getCards()), bigCard, null, true);
|
||||||
deckArea.getSideboardList().loadCards(new CardsView(deck.getSideboard()), bigCard, null);
|
deckArea.getSideboardList().loadCards(new CardsView(deck.getSideboard()), bigCard, null, true);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue