added deck construction to draft

This commit is contained in:
BetaSteward 2011-01-09 23:33:22 -05:00
parent d62b512a72
commit c79758f0e5
19 changed files with 154 additions and 25 deletions

View file

@ -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">
<AuxValues>

View file

@ -70,8 +70,22 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
jScrollPane1.getViewport().setOpaque(false);
}
public void loadCards(List<Card> cards, BigCard bigCard) {
this.bigCard = bigCard;
this.btnBooster.setVisible(false);
this.btnClear.setVisible(false);
this.cbExpansionSet.setVisible(false);
cards.clear();
for (Card card: cards) {
cards.add(card);
}
}
public void loadCards(BigCard bigCard) {
this.bigCard = bigCard;
this.btnBooster.setVisible(true);
this.btnClear.setVisible(true);
this.cbExpansionSet.setVisible(true);
Object[] l = Sets.getInstance().values().toArray();
Arrays.sort(l, new Comparator<Object>() {
@Override
@ -106,13 +120,21 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
private void filterCards() {
try {
List<Card> filteredCards = new ArrayList<Card>();
setCursor(new Cursor(Cursor.WAIT_CURSOR));
cards.clear();
for (Card card: CardsStorage.getAllCards()) {
if (filter.match(card))
cards.add(card);
if (!cards.isEmpty()) {
for (Card card: cards) {
if (filter.match(card))
filteredCards.add(card);
}
}
this.cardGrid.loadCards(new CardsView(cards), bigCard, null);
else {
for (Card card: CardsStorage.getAllCards()) {
if (filter.match(card))
filteredCards.add(card);
}
}
this.cardGrid.loadCards(new CardsView(filteredCards), bigCard, null);
}
finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
@ -466,7 +488,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearActionPerformed
cards.clear();
this.cardGrid.loadCards(new CardsView(cards), bigCard, null);
filterCards();
// this.cardGrid.loadCards(new CardsView(cards), bigCard, null);
}//GEN-LAST:event_btnClearActionPerformed
private void btnBoosterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBoosterActionPerformed
@ -474,7 +497,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
for (Card card: booster) {
cards.add(card);
}
this.cardGrid.loadCards(new CardsView(cards), bigCard, null);
filterCards();
// this.cardGrid.loadCards(new CardsView(cards), bigCard, null);
}//GEN-LAST:event_btnBoosterActionPerformed

View file

@ -52,6 +52,7 @@ import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -70,6 +71,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
private boolean isShowCardInfo = false;
private UUID tableId;
/** Creates new form DeckEditorPanel */
public DeckEditorPanel() {
initComponents();
@ -86,17 +88,21 @@ public class DeckEditorPanel extends javax.swing.JPanel {
}
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId) {
if (deck != null)
if (deck != null) {
this.deck = deck;
this.tableId = tableId;
showDeckEditor(mode);
this.tableId = tableId;
this.btnSubmit.setVisible(mode == DeckEditorMode.Sideboard || mode == DeckEditorMode.Limited);
this.cardSelector.loadCards(new ArrayList<Card>(deck.getSideboard()), this.bigCard);
}
else {
this.cardSelector.loadCards(this.bigCard);
}
init();
}
public void showDeckEditor(DeckEditorMode mode) {
this.cardSelector.loadCards(this.bigCard);
private void init() {
this.cardSelector.setVisible(true);
this.jPanel1.setVisible(true);
this.btnSubmit.setVisible(mode == DeckEditorMode.Sideboard);
this.cardSelector.getCardsList().clearCardEventListeners();
this.cardSelector.getCardsList().addCardEventListener(
new Listener<Event> () {