mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
add card sorting to draft screen
This commit is contained in:
parent
c8c59933eb
commit
d1f0f5bf43
6 changed files with 37 additions and 95 deletions
|
@ -27,7 +27,7 @@
|
|||
<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="625" max="32767" attributes="0"/>
|
||||
<Component id="jScrollPane1" alignment="0" pref="636" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
|
@ -35,7 +35,7 @@
|
|||
<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="258" max="32767" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="366" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
@ -65,7 +65,7 @@
|
|||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkPiles" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cbSortBy" pref="300" max="32767" attributes="0"/>
|
||||
<Component id="cbSortBy" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
|
|
@ -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))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
@ -336,57 +338,3 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
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) {
|
||||
int val = o1.getRarity().compareTo(o2.getRarity());
|
||||
if (val == 0) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CardViewCostComparator implements Comparator<CardView> {
|
||||
|
||||
@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<CardView> {
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -11,7 +11,6 @@
|
|||
<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>
|
||||
|
|
|
@ -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<CardView> sortedCards = new ArrayList<CardView>(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);
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="draftBooster" max="32767" attributes="0"/>
|
||||
<Component id="draftPicks" alignment="0" pref="570" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="draftPicks" pref="582" max="32767" attributes="0"/>
|
||||
<Component id="draftBooster" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
|
@ -34,7 +34,7 @@
|
|||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="draftPicks" pref="103" max="32767" attributes="0"/>
|
||||
<Component id="draftPicks" pref="106" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
<Component id="draftBooster" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
|
@ -125,7 +125,7 @@
|
|||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="txtTimeRemaining" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblMessage" pref="29" max="32767" attributes="0"/>
|
||||
<Component id="lblMessage" pref="32" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="bigCard" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
|
@ -218,7 +218,7 @@
|
|||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="568" max="32767" attributes="0"/>
|
||||
<EmptySpace min="0" pref="580" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
|
@ -228,16 +228,7 @@
|
|||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Container class="mage.client.cards.CardGrid" name="draftPicks">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JLayeredPaneSupportLayout"/>
|
||||
</Container>
|
||||
<Component class="mage.client.cards.CardsList" name="draftPicks">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
|
|
@ -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<Event> () {
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue