added sorting and counts to deck editor

This commit is contained in:
BetaSteward 2011-02-11 22:57:22 -05:00
parent f36254445a
commit d217d332b6
15 changed files with 372 additions and 507 deletions

View file

@ -50,6 +50,7 @@ import java.util.UUID;
import java.util.Map.Entry;
import mage.cards.MageCard;
import mage.client.constants.Constants.SortBy;
import mage.client.plugins.impl.Plugins;
import mage.client.util.Config;
import mage.client.util.Event;
@ -74,7 +75,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener
setOpaque(false);
}
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
public void loadCards(CardsView showCards, SortBy sortBy, BigCard bigCard, UUID gameId) {
this.bigCard = bigCard;
this.gameId = gameId;
for (CardView card: showCards.values()) {
@ -89,7 +90,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener
i.remove();
}
}
drawCards();
drawCards(sortBy);
this.setVisible(true);
}
@ -105,7 +106,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener
cards.put(card.getId(), cardImg);
}
public void drawCards() {
public void drawCards(SortBy sortBy) {
int maxWidth = this.getParent().getWidth();
int numColumns = maxWidth / Config.dimensions.frameWidth;
int curColumn = 0;
@ -113,7 +114,20 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener
if (cards.size() > 0) {
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
List<MageCard> sortedCards = new ArrayList<MageCard>(cards.values());
Collections.sort(sortedCards, new CardComparator());
switch (sortBy) {
case NAME:
Collections.sort(sortedCards, new CardNameComparator());
break;
case RARITY:
Collections.sort(sortedCards, new CardRarityComparator());
break;
case COLOR:
Collections.sort(sortedCards, new CardColorComparator());
break;
case CASTING_COST:
Collections.sort(sortedCards, new CardCostComparator());
break;
}
for (MageCard cardImg: sortedCards) {
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
cardImg.setBounds(rectangle);
@ -229,11 +243,38 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener
}
}
class CardComparator implements Comparator<MageCard> {
class CardNameComparator implements Comparator<MageCard> {
@Override
public int compare(MageCard o1, MageCard o2) {
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
}
}
class CardRarityComparator implements Comparator<MageCard> {
@Override
public int compare(MageCard o1, MageCard o2) {
return o1.getOriginal().getRarity().compareTo(o2.getOriginal().getRarity());
}
}
class CardCostComparator implements Comparator<MageCard> {
@Override
public int compare(MageCard o1, MageCard o2) {
return Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(Integer.valueOf(o2.getOriginal().getConvertedManaCost()));
}
}
class CardColorComparator implements Comparator<MageCard> {
@Override
public int compare(MageCard o1, MageCard o2) {
return o1.getOriginal().getColor().compareTo(o2.getOriginal().getColor());
}
}

View file

@ -21,17 +21,27 @@
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" pref="553" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="321" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
@ -41,5 +51,65 @@
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel1">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="lblCount" max="32767" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="lblCreatureCount" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="lblLandCount" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="cbSortBy" min="-2" pref="338" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cbSortBy" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblCount" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblCreatureCount" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblLandCount" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JComboBox" name="cbSortBy">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbSortByActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblCount">
<Properties>
<Property name="text" type="java.lang.String" value="Card Count"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblCreatureCount">
<Properties>
<Property name="text" type="java.lang.String" value="Creature Count"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblLandCount">
<Properties>
<Property name="text" type="java.lang.String" value="Land Count"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View file

@ -44,8 +44,11 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;
import javax.swing.DefaultComboBoxModel;
import mage.Constants.CardType;
import mage.cards.MageCard;
import mage.client.constants.Constants.SortBy;
import mage.client.plugins.impl.Plugins;
import mage.client.util.Config;
import mage.client.util.Event;
@ -61,6 +64,9 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
protected CardEventSource cardEventSource = new CardEventSource();
private Dimension cardDimension;
private CardsView cards;
protected BigCard bigCard;
protected UUID gameId;
/** Creates new form Cards */
public CardsList() {
@ -68,32 +74,64 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
jScrollPane1.setOpaque(false);
cardArea.setOpaque(false);
jScrollPane1.getViewport().setOpaque(false);
cbSortBy.setModel(new DefaultComboBoxModel(SortBy.values()));
}
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
loadCards(showCards, bigCard, gameId, false);
loadCards(showCards, bigCard, gameId, SortBy.UNSORTED);
}
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId, boolean sorted) {
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId, SortBy sortBy) {
//FIXME: why we remove all cards? for performance it's better to merge changes
cards = showCards;
this.bigCard = bigCard;
this.gameId = gameId;
drawCards(sortBy);
}
private void drawCards(SortBy sortBy) {
int maxWidth = this.getParent().getWidth();
int numColumns = maxWidth / Config.dimensions.frameWidth;
int curColumn = 0;
int curRow = 0;
int landCount = 0;
int creatureCount = 0;
cardArea.removeAll();
if (showCards != null && showCards.size() > 0) {
if (cards != null && cards.size() > 0) {
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
int count = 0;
List<CardView> sortedCards = new ArrayList<CardView>(showCards.values());
if (sorted)
Collections.sort(sortedCards, new CardViewComparator());
List<CardView> sortedCards = new ArrayList<CardView>(cards.values());
switch (sortBy) {
case NAME:
Collections.sort(sortedCards, new CardViewNameComparator());
break;
case RARITY:
Collections.sort(sortedCards, new CardViewRarityComparator());
break;
case COLOR:
Collections.sort(sortedCards, new CardViewColorComparator());
break;
case CASTING_COST:
Collections.sort(sortedCards, new CardViewCostComparator());
break;
}
for (CardView card: sortedCards) {
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
addCard(card, bigCard, gameId, rectangle);
if (count >= 10) {
rectangle.translate(Config.dimensions.frameWidth, -200);
count = 0;
} else {
rectangle.translate(0, 20);
count++;
if (card.getCardTypes().contains(CardType.LAND))
landCount++;
if (card.getCardTypes().contains(CardType.CREATURE))
creatureCount++;
curColumn++;
if (curColumn == numColumns) {
curColumn = 0;
curRow++;
}
}
}
this.lblCount.setText("Count: " + Integer.toString(cards.size()));
this.lblCreatureCount.setText("Creatures: " + Integer.toString(creatureCount));
this.lblLandCount.setText("Lands: " + Integer.toString(landCount));
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight + 200));
cardArea.revalidate();
this.revalidate();
@ -133,20 +171,81 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
jScrollPane1 = new javax.swing.JScrollPane();
cardArea = new javax.swing.JLayeredPane();
jPanel1 = new javax.swing.JPanel();
cbSortBy = new javax.swing.JComboBox();
lblCount = new javax.swing.JLabel();
lblCreatureCount = new javax.swing.JLabel();
lblLandCount = new javax.swing.JLabel();
setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
setPreferredSize((!Beans.isDesignTime())?(new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight)):(new Dimension(100, 100)));
setLayout(new java.awt.BorderLayout());
jScrollPane1.setViewportView(cardArea);
add(jScrollPane1, java.awt.BorderLayout.CENTER);
cbSortBy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbSortBy.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbSortByActionPerformed(evt);
}
});
lblCount.setText("Card Count");
lblCreatureCount.setText("Creature Count");
lblLandCount.setText("Land Count");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(lblCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lblCreatureCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lblLandCount)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(cbSortBy, javax.swing.GroupLayout.PREFERRED_SIZE, 338, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbSortBy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblCount)
.addComponent(lblCreatureCount)
.addComponent(lblLandCount))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 553, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSortByActionPerformed
drawCards((SortBy) cbSortBy.getSelectedItem());
}//GEN-LAST:event_cbSortByActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLayeredPane cardArea;
private javax.swing.JComboBox cbSortBy;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lblCount;
private javax.swing.JLabel lblCreatureCount;
private javax.swing.JLabel lblLandCount;
// End of variables declaration//GEN-END:variables
@Override
@ -180,11 +279,38 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
}
class CardViewComparator implements Comparator<CardView> {
class CardViewNameComparator implements Comparator<CardView> {
@Override
public int compare(CardView o1, CardView o2) {
return o1.getName().compareTo(o2.getName());
}
}
class CardViewRarityComparator implements Comparator<CardView> {
@Override
public int compare(CardView o1, CardView o2) {
return o1.getRarity().compareTo(o2.getRarity());
}
}
class CardViewCostComparator implements Comparator<CardView> {
@Override
public int compare(CardView o1, CardView o2) {
return Integer.valueOf(o1.getConvertedManaCost()).compareTo(Integer.valueOf(o2.getConvertedManaCost()));
}
}
class CardViewColorComparator implements Comparator<CardView> {
@Override
public int compare(CardView o1, CardView o2) {
return o1.getColor().compareTo(o2.getColor());
}
}

View file

@ -92,4 +92,23 @@ public final class Constants {
Sideboard
}
public enum SortBy {
CASTING_COST ("Casting Cost"),
RARITY ("Rarity"),
COLOR ("Color"),
NAME ("Name"),
UNSORTED ("Unsorted");
private String text;
SortBy(String text) {
this.text = text;
}
@Override
public String toString() {
return text;
}
}
}

View file

@ -151,17 +151,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnClearActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnAddLand">
<Properties>
<Property name="text" type="java.lang.String" value="Add Land"/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAddLandActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
@ -266,6 +255,21 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rdoPlaneswalkersActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JComboBox" name="cbSortBy">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbSortByActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>

View file

@ -45,6 +45,7 @@ import mage.cards.ExpansionSet;
import mage.client.cards.BigCard;
import mage.client.cards.CardGrid;
import mage.client.cards.CardsStorage;
import mage.client.constants.Constants.SortBy;
import mage.filter.Filter.ComparisonScope;
import mage.filter.FilterCard;
import mage.sets.Sets;
@ -68,13 +69,13 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
cardGrid.setOpaque(false);
jScrollPane1.setOpaque(false);
jScrollPane1.getViewport().setOpaque(false);
cbSortBy.setModel(new DefaultComboBoxModel(SortBy.values()));
}
public void loadCards(List<Card> sideboard, BigCard bigCard, boolean construct) {
this.bigCard = bigCard;
this.btnBooster.setVisible(false);
this.btnClear.setVisible(false);
this.btnAddLand.setVisible(construct);
this.cbExpansionSet.setVisible(false);
this.cards.clear();
for (Card card: sideboard) {
@ -88,7 +89,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
this.bigCard = bigCard;
this.btnBooster.setVisible(true);
this.btnClear.setVisible(true);
this.btnAddLand.setVisible(false);
this.cbExpansionSet.setVisible(true);
Object[] l = Sets.getInstance().values().toArray();
Arrays.sort(l, new Comparator<Object>() {
@ -142,7 +142,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
filteredCards.add(card);
}
}
this.cardGrid.loadCards(new CardsView(filteredCards), bigCard, null);
this.cardGrid.loadCards(new CardsView(filteredCards), (SortBy) cbSortBy.getSelectedItem(), bigCard, null);
}
finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
@ -188,7 +188,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
cbExpansionSet = new javax.swing.JComboBox();
btnBooster = new javax.swing.JButton();
btnClear = new javax.swing.JButton();
btnAddLand = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
cardGrid = new mage.client.cards.CardGrid();
tbTypes = new javax.swing.JToolBar();
@ -199,6 +198,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
rdoInstants = new javax.swing.JRadioButton();
rdoSorceries = new javax.swing.JRadioButton();
rdoPlaneswalkers = new javax.swing.JRadioButton();
cbSortBy = new javax.swing.JComboBox();
tbColor.setFloatable(false);
tbColor.setRollover(true);
@ -305,17 +305,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
});
tbColor.add(btnClear);
btnAddLand.setText("Add Land");
btnAddLand.setFocusable(false);
btnAddLand.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnAddLand.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnAddLand.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAddLandActionPerformed(evt);
}
});
tbColor.add(btnAddLand);
jScrollPane1.setViewportView(cardGrid);
tbTypes.setFloatable(false);
@ -405,6 +394,14 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
});
tbTypes.add(rdoPlaneswalkers);
cbSortBy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbSortBy.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbSortByActionPerformed(evt);
}
});
tbTypes.add(cbSortBy);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@ -531,17 +528,18 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
filterCards();
}//GEN-LAST:event_btnBoosterActionPerformed
private void btnAddLandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddLandActionPerformed
}//GEN-LAST:event_btnAddLandActionPerformed
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSortByActionPerformed
if (cbSortBy.getSelectedItem() instanceof SortBy)
this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem());
}//GEN-LAST:event_cbSortByActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnAddLand;
private javax.swing.JButton btnBooster;
private javax.swing.JButton btnClear;
private mage.client.cards.CardGrid cardGrid;
private javax.swing.JComboBox cbExpansionSet;
private javax.swing.JComboBox cbSortBy;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JRadioButton rdoArtifacts;
private javax.swing.JRadioButton rdoBlack;
@ -562,22 +560,26 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
@Override
public void componentResized(ComponentEvent e) {
this.cardGrid.drawCards();
if (cbSortBy.getSelectedItem() instanceof SortBy)
this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem());
}
@Override
public void componentMoved(ComponentEvent e) {
this.cardGrid.drawCards();
if (cbSortBy.getSelectedItem() instanceof SortBy)
this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem());
}
@Override
public void componentShown(ComponentEvent e) {
this.cardGrid.drawCards();
if (cbSortBy.getSelectedItem() instanceof SortBy)
this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem());
}
@Override
public void componentHidden(ComponentEvent e) {
this.cardGrid.drawCards();
if (cbSortBy.getSelectedItem() instanceof SortBy)
this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem());
}
}

View file

@ -38,6 +38,7 @@ package mage.client.deckeditor;
import mage.cards.decks.Deck;
import mage.client.cards.BigCard;
import mage.client.cards.CardsList;
import mage.client.constants.Constants.SortBy;
import mage.client.util.Event;
import mage.client.util.Listener;
import mage.view.CardsView;
@ -61,9 +62,9 @@ public class DeckArea extends javax.swing.JPanel {
}
public void loadDeck(Deck deck, BigCard bigCard) {
deckList.loadCards(new CardsView(deck.getCards()), bigCard, null, true);
deckList.loadCards(new CardsView(deck.getCards()), bigCard, null, SortBy.NAME);
if (sideboardList.isVisible())
sideboardList.loadCards(new CardsView(deck.getSideboard()), bigCard, null, true);
sideboardList.loadCards(new CardsView(deck.getSideboard()), bigCard, null, SortBy.NAME);
}
public void addDeckEventListener(Listener<Event> listener) {

View file

@ -40,6 +40,7 @@ import java.awt.event.ActionListener;
import java.util.UUID;
import javax.swing.Timer;
import mage.client.MageFrame;
import mage.client.constants.Constants.SortBy;
import mage.client.remote.Session;
import mage.client.util.Event;
import mage.client.util.Listener;
@ -97,7 +98,7 @@ public class DraftPanel extends javax.swing.JPanel {
public void loadBooster(DraftPickView draftPickView) {
draftBooster.loadBooster(draftPickView.getBooster(), bigCard);
draftPicks.loadCards(draftPickView.getPicks(), bigCard, null);
draftPicks.loadCards(draftPickView.getPicks(), SortBy.NAME, bigCard, null);
this.draftBooster.clearCardEventListeners();
this.draftBooster.addCardEventListener(
new Listener<Event> () {
@ -107,7 +108,7 @@ public class DraftPanel extends javax.swing.JPanel {
DraftPickView view = session.sendCardPick(draftId, (UUID)event.getSource());
if (view != null) {
draftBooster.loadBooster(view.getBooster(), bigCard);
draftPicks.loadCards(view.getPicks(), bigCard, null);
draftPicks.loadCards(view.getPicks(), SortBy.NAME, bigCard, null);
setMessage("Waiting for other players");
}
}