forked from External/mage
added sorting and counts to deck editor
This commit is contained in:
parent
f36254445a
commit
d217d332b6
15 changed files with 372 additions and 507 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue