diff --git a/Mage.Client/src/main/java/mage/client/cards/CardsList.form b/Mage.Client/src/main/java/mage/client/cards/CardsList.form index 3046438e2e..918e86575b 100644 --- a/Mage.Client/src/main/java/mage/client/cards/CardsList.form +++ b/Mage.Client/src/main/java/mage/client/cards/CardsList.form @@ -27,7 +27,7 @@ - + @@ -35,7 +35,7 @@ - + @@ -65,7 +65,7 @@ - + diff --git a/Mage.Client/src/main/java/mage/client/cards/CardsList.java b/Mage.Client/src/main/java/mage/client/cards/CardsList.java index 2d003a03ee..9e81058920 100644 --- a/Mage.Client/src/main/java/mage/client/cards/CardsList.java +++ b/Mage.Client/src/main/java/mage/client/cards/CardsList.java @@ -41,16 +41,18 @@ import java.awt.event.MouseListener; 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 javax.swing.DefaultComboBoxModel; import mage.Constants.CardType; -import mage.ObjectColor; import mage.cards.MageCard; import mage.client.constants.Constants.SortBy; import mage.client.plugins.impl.Plugins; +import mage.client.util.CardViewColorComparator; +import mage.client.util.CardViewCostComparator; +import mage.client.util.CardViewNameComparator; +import mage.client.util.CardViewRarityComparator; import mage.client.util.Config; import mage.client.util.Event; import mage.client.util.Listener; @@ -258,7 +260,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(chkPiles) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(cbSortBy, 0, 300, Short.MAX_VALUE)) + .addComponent(cbSortBy, 0, 0, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -275,14 +277,14 @@ public class CardsList extends javax.swing.JPanel implements MouseListener { 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, 625, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 636, 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, 258, Short.MAX_VALUE)) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 366, Short.MAX_VALUE)) ); }// //GEN-END:initComponents @@ -336,57 +338,3 @@ public class CardsList extends javax.swing.JPanel implements MouseListener { } } - -class CardViewNameComparator implements Comparator { - - @Override - public int compare(CardView o1, CardView o2) { - return o1.getName().compareTo(o2.getName()); - } - -} - -class CardViewRarityComparator implements Comparator { - - @Override - public int compare(CardView o1, CardView o2) { - int val = o1.getRarity().compareTo(o2.getRarity()); - if (val == 0) { - return o1.getName().compareTo(o2.getName()); - } - else { - return val; - } - } - -} - -class CardViewCostComparator implements Comparator { - - @Override - public int compare(CardView o1, CardView o2) { - int val = Integer.valueOf(o1.getConvertedManaCost()).compareTo(Integer.valueOf(o2.getConvertedManaCost())); - if (val == 0) { - return o1.getName().compareTo(o2.getName()); - } - else { - return val; - } - } - -} - -class CardViewColorComparator implements Comparator { - - @Override - public int compare(CardView o1, CardView o2) { - int val = o1.getColor().compareTo(o2.getColor()); - if (val == 0) { - return o1.getName().compareTo(o2.getName()); - } - else { - return val; - } - } - -} \ No newline at end of file diff --git a/Mage.Client/src/main/java/mage/client/cards/DraftGrid.form b/Mage.Client/src/main/java/mage/client/cards/DraftGrid.form index 797927e8af..6531030bb3 100644 --- a/Mage.Client/src/main/java/mage/client/cards/DraftGrid.form +++ b/Mage.Client/src/main/java/mage/client/cards/DraftGrid.form @@ -11,7 +11,6 @@ - diff --git a/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java b/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java index c6273795dc..ca86e50af5 100644 --- a/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java +++ b/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java @@ -34,13 +34,17 @@ package mage.client.cards; -import java.awt.*; +import java.awt.Dimension; +import java.awt.Rectangle; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; -import mage.cards.CardDimensions; import mage.cards.MageCard; import mage.client.plugins.impl.Plugins; +import mage.client.util.CardViewRarityComparator; import mage.client.util.Config; import mage.view.CardView; import mage.view.CardsView; @@ -69,7 +73,9 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener { int curRow = 0; Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight); Dimension dimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight); - for (CardView card: booster.values()) { + List sortedCards = new ArrayList(booster.values()); + Collections.sort(sortedCards, new CardViewRarityComparator()); + for (CardView card: sortedCards) { MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, dimension, null, false); cardImg.addMouseListener(this); add(cardImg); diff --git a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.form b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.form index 97a1ed3ecf..7965883089 100644 --- a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.form +++ b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.form @@ -23,9 +23,9 @@ - - - + + + @@ -34,7 +34,7 @@ - + @@ -125,7 +125,7 @@ - + @@ -218,7 +218,7 @@ - + @@ -228,16 +228,7 @@ - - - - - - - - - - - + + diff --git a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java index 4d3c3e775d..b9531dcb82 100644 --- a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java +++ b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java @@ -98,7 +98,7 @@ public class DraftPanel extends javax.swing.JPanel { public void loadBooster(DraftPickView draftPickView) { draftBooster.loadBooster(draftPickView.getBooster(), bigCard); - draftPicks.loadCards(draftPickView.getPicks(), SortBy.NAME, false, bigCard, null); + draftPicks.loadCards(draftPickView.getPicks(), bigCard, null); this.draftBooster.clearCardEventListeners(); this.draftBooster.addCardEventListener( new Listener () { @@ -108,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(), SortBy.NAME, false, bigCard, null); + draftPicks.loadCards(view.getPicks(), bigCard, null); setMessage("Waiting for other players"); } } @@ -167,7 +167,7 @@ public class DraftPanel extends javax.swing.JPanel { txtTimeRemaining = new javax.swing.JTextField(); lblMessage = new javax.swing.JLabel(); draftBooster = new mage.client.cards.DraftGrid(); - draftPicks = new mage.client.cards.CardGrid(); + draftPicks = new mage.client.cards.CardsList(); jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); @@ -259,7 +259,7 @@ public class DraftPanel extends javax.swing.JPanel { .addGap(18, 18, 18) .addComponent(txtTimeRemaining, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(lblMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE) + .addComponent(lblMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) ); @@ -270,15 +270,13 @@ public class DraftPanel extends javax.swing.JPanel { draftBooster.setLayout(draftBoosterLayout); draftBoosterLayout.setHorizontalGroup( draftBoosterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 568, Short.MAX_VALUE) + .addGap(0, 580, Short.MAX_VALUE) ); draftBoosterLayout.setVerticalGroup( draftBoosterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 452, Short.MAX_VALUE) ); - draftPicks.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -286,15 +284,15 @@ public class DraftPanel extends javax.swing.JPanel { .addGroup(layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(draftBooster, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(draftPicks, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 570, Short.MAX_VALUE))) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(draftPicks, javax.swing.GroupLayout.DEFAULT_SIZE, 582, Short.MAX_VALUE) + .addComponent(draftBooster, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(draftPicks, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE) + .addComponent(draftPicks, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE) .addGap(0, 0, 0) .addComponent(draftBooster, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) ); @@ -307,7 +305,7 @@ public class DraftPanel extends javax.swing.JPanel { private javax.swing.JCheckBox chkPack2; private javax.swing.JCheckBox chkPack3; private mage.client.cards.DraftGrid draftBooster; - private mage.client.cards.CardGrid draftPicks; + private mage.client.cards.CardsList draftPicks; private javax.swing.JPanel jPanel1; private javax.swing.JSeparator jSeparator1; private javax.swing.JLabel lblCardNo;