- The Constructed deck editor now has an option to either show all cards from all sets or show unique cards only (see the Preferences tab), the Sealed Mode, Draft Mode, and Quest Mode deck editors will always show cards from all sets in order to avoid issues and confusion.

This commit is contained in:
Agetian
2012-12-07 15:52:29 +00:00
parent a004350e7d
commit d067f4cb35
10 changed files with 112 additions and 9 deletions

View File

@@ -2,6 +2,7 @@
<preferences type="editor"> <preferences type="editor">
<pref name="stats_catalog" value="true"></pref> <pref name="stats_catalog" value="true"></pref>
<pref name="stats_deck" value="true"></pref> <pref name="stats_deck" value="true"></pref>
<pref name="display_unique_only" value="false"></pref>
<col enumval="CAT_QUANTITY" identifier="Quantity" show="true" sortpriority="1" sortstate="DESC" width="39"></col> <col enumval="CAT_QUANTITY" identifier="Quantity" show="true" sortpriority="1" sortstate="DESC" width="39"></col>
<col enumval="CAT_NAME" identifier="Name" show="true" sortpriority="2" sortstate="DESC" width="50"></col> <col enumval="CAT_NAME" identifier="Name" show="true" sortpriority="2" sortstate="DESC" width="50"></col>
<col enumval="CAT_COST" identifier="Cost" show="true" sortpriority="3" sortstate="DESC" width="36"></col> <col enumval="CAT_COST" identifier="Cost" show="true" sortpriority="3" sortstate="DESC" width="36"></col>

View File

@@ -49,7 +49,8 @@ public class SEditorIO {
/** Preferences (must match with PREFS file). */ /** Preferences (must match with PREFS file). */
public enum EditorPreference { /** */ public enum EditorPreference { /** */
stats_deck, /** */ stats_deck, /** */
stats_catalog stats_catalog,
display_unique_only
} }
private static final XMLEventFactory EVENT_FACTORY = XMLEventFactory.newInstance(); private static final XMLEventFactory EVENT_FACTORY = XMLEventFactory.newInstance();

View File

@@ -24,6 +24,7 @@ import com.google.common.base.Supplier;
import forge.Singletons; import forge.Singletons;
import forge.deck.Deck; import forge.deck.Deck;
import forge.gui.deckeditor.SEditorIO; import forge.gui.deckeditor.SEditorIO;
import forge.gui.deckeditor.SEditorIO.EditorPreference;
import forge.gui.deckeditor.SEditorUtil; import forge.gui.deckeditor.SEditorUtil;
import forge.gui.deckeditor.tables.DeckController; import forge.gui.deckeditor.tables.DeckController;
import forge.gui.deckeditor.tables.SColumnUtil; import forge.gui.deckeditor.tables.SColumnUtil;
@@ -61,8 +62,10 @@ public final class CEditorConstructed extends ACEditorBase<CardPrinted, Deck> {
public CEditorConstructed() { public CEditorConstructed() {
super(); super();
final EditorTableView<CardPrinted> tblCatalog = new EditorTableView<CardPrinted>(true, CardPrinted.class); boolean wantUnique = SEditorIO.getPref(EditorPreference.display_unique_only);
final EditorTableView<CardPrinted> tblDeck = new EditorTableView<CardPrinted>(true, CardPrinted.class);
final EditorTableView<CardPrinted> tblCatalog = new EditorTableView<CardPrinted>(wantUnique, CardPrinted.class);
final EditorTableView<CardPrinted> tblDeck = new EditorTableView<CardPrinted>(wantUnique, CardPrinted.class);
VCardCatalog.SINGLETON_INSTANCE.setTableView(tblCatalog.getTable()); VCardCatalog.SINGLETON_INSTANCE.setTableView(tblCatalog.getTable());
VCurrentDeck.SINGLETON_INSTANCE.setTableView(tblDeck.getTable()); VCurrentDeck.SINGLETON_INSTANCE.setTableView(tblDeck.getTable());

View File

@@ -26,6 +26,8 @@ import forge.deck.Deck;
import forge.deck.DeckGroup; import forge.deck.DeckGroup;
import forge.game.limited.BoosterDraft; import forge.game.limited.BoosterDraft;
import forge.game.limited.IBoosterDraft; import forge.game.limited.IBoosterDraft;
import forge.gui.deckeditor.SEditorIO;
import forge.gui.deckeditor.SEditorIO.EditorPreference;
import forge.gui.deckeditor.tables.DeckController; import forge.gui.deckeditor.tables.DeckController;
import forge.gui.deckeditor.tables.EditorTableView; import forge.gui.deckeditor.tables.EditorTableView;
import forge.gui.deckeditor.tables.SColumnUtil; import forge.gui.deckeditor.tables.SColumnUtil;
@@ -65,12 +67,15 @@ public class CEditorDraftingProcess extends ACEditorBase<CardPrinted, DeckGroup>
* Updates the deck editor UI as necessary draft selection mode. * Updates the deck editor UI as necessary draft selection mode.
*/ */
public CEditorDraftingProcess() { public CEditorDraftingProcess() {
final EditorTableView<CardPrinted> tblCatalog = new EditorTableView<CardPrinted>(true, CardPrinted.class); final EditorTableView<CardPrinted> tblCatalog = new EditorTableView<CardPrinted>(false, CardPrinted.class);
final EditorTableView<CardPrinted> tblDeck = new EditorTableView<CardPrinted>(true, CardPrinted.class); final EditorTableView<CardPrinted> tblDeck = new EditorTableView<CardPrinted>(false, CardPrinted.class);
VCardCatalog.SINGLETON_INSTANCE.setTableView(tblCatalog.getTable()); VCardCatalog.SINGLETON_INSTANCE.setTableView(tblCatalog.getTable());
VCurrentDeck.SINGLETON_INSTANCE.setTableView(tblDeck.getTable()); VCurrentDeck.SINGLETON_INSTANCE.setTableView(tblDeck.getTable());
tblCatalog.setAlwaysNonUnique(true);
tblDeck.setAlwaysNonUnique(true);
this.setTableCatalog(tblCatalog); this.setTableCatalog(tblCatalog);
this.setTableDeck(tblDeck); this.setTableDeck(tblDeck);
} }

View File

@@ -23,6 +23,7 @@ import forge.Command;
import forge.deck.Deck; import forge.deck.Deck;
import forge.deck.DeckGroup; import forge.deck.DeckGroup;
import forge.gui.deckeditor.SEditorIO; import forge.gui.deckeditor.SEditorIO;
import forge.gui.deckeditor.SEditorIO.EditorPreference;
import forge.gui.deckeditor.SEditorUtil; import forge.gui.deckeditor.SEditorUtil;
import forge.gui.deckeditor.tables.DeckController; import forge.gui.deckeditor.tables.DeckController;
import forge.gui.deckeditor.tables.EditorTableView; import forge.gui.deckeditor.tables.EditorTableView;
@@ -56,12 +57,15 @@ public final class CEditorLimited extends ACEditorBase<CardPrinted, DeckGroup> {
* @param deckMap0 &emsp; {@link forge.deck.DeckGroup}<{@link forge.util.IStorage}> * @param deckMap0 &emsp; {@link forge.deck.DeckGroup}<{@link forge.util.IStorage}>
*/ */
public CEditorLimited(final IStorage<DeckGroup> deckMap0) { public CEditorLimited(final IStorage<DeckGroup> deckMap0) {
final EditorTableView<CardPrinted> tblCatalog = new EditorTableView<CardPrinted>(true, CardPrinted.class); final EditorTableView<CardPrinted> tblCatalog = new EditorTableView<CardPrinted>(false, CardPrinted.class);
final EditorTableView<CardPrinted> tblDeck = new EditorTableView<CardPrinted>(true, CardPrinted.class); final EditorTableView<CardPrinted> tblDeck = new EditorTableView<CardPrinted>(false, CardPrinted.class);
VCardCatalog.SINGLETON_INSTANCE.setTableView(tblCatalog.getTable()); VCardCatalog.SINGLETON_INSTANCE.setTableView(tblCatalog.getTable());
VCurrentDeck.SINGLETON_INSTANCE.setTableView(tblDeck.getTable()); VCurrentDeck.SINGLETON_INSTANCE.setTableView(tblDeck.getTable());
tblCatalog.setAlwaysNonUnique(true);
tblDeck.setAlwaysNonUnique(true);
this.setTableCatalog(tblCatalog); this.setTableCatalog(tblCatalog);
this.setTableDeck(tblDeck); this.setTableDeck(tblDeck);

View File

@@ -7,6 +7,7 @@ import java.util.HashMap;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import forge.Command; import forge.Command;
import forge.gui.deckeditor.CDeckEditorUI;
import forge.gui.deckeditor.SEditorIO; import forge.gui.deckeditor.SEditorIO;
import forge.gui.deckeditor.SEditorIO.EditorPreference; import forge.gui.deckeditor.SEditorIO.EditorPreference;
import forge.gui.deckeditor.tables.SColumnUtil; import forge.gui.deckeditor.tables.SColumnUtil;
@@ -85,6 +86,8 @@ public enum CEditorPreferences implements ICDoc {
SEditorIO.getPref(EditorPreference.stats_catalog)); SEditorIO.getPref(EditorPreference.stats_catalog));
VEditorPreferences.SINGLETON_INSTANCE.getChbDeckStats().setSelected( VEditorPreferences.SINGLETON_INSTANCE.getChbDeckStats().setSelected(
SEditorIO.getPref(EditorPreference.stats_deck)); SEditorIO.getPref(EditorPreference.stats_deck));
VEditorPreferences.SINGLETON_INSTANCE.getChbCardDisplayUnique().setSelected(
SEditorIO.getPref(EditorPreference.display_unique_only));
if (!SEditorIO.getPref(EditorPreference.stats_deck)) { if (!SEditorIO.getPref(EditorPreference.stats_deck)) {
VCurrentDeck.SINGLETON_INSTANCE.getPnlStats().setVisible(false); VCurrentDeck.SINGLETON_INSTANCE.getPnlStats().setVisible(false);
@@ -92,6 +95,15 @@ public enum CEditorPreferences implements ICDoc {
if (!SEditorIO.getPref(EditorPreference.stats_catalog)) { if (!SEditorIO.getPref(EditorPreference.stats_catalog)) {
VCardCatalog.SINGLETON_INSTANCE.getPnlStats().setVisible(false); VCardCatalog.SINGLETON_INSTANCE.getPnlStats().setVisible(false);
} }
boolean wantUnique = SEditorIO.getPref(EditorPreference.display_unique_only);
ACEditorBase<?, ?> curEditor = CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController();
if (curEditor != null) {
curEditor.getTableCatalog().setWantUnique(wantUnique);
curEditor.getTableCatalog().updateView(true);
curEditor.getTableDeck().setWantUnique(wantUnique);
curEditor.getTableDeck().updateView(true);
}
VEditorPreferences.SINGLETON_INSTANCE.getChbCatalogStats().addItemListener(new ItemListener() { VEditorPreferences.SINGLETON_INSTANCE.getChbCatalogStats().addItemListener(new ItemListener() {
@Override public void itemStateChanged(final ItemEvent e) { @Override public void itemStateChanged(final ItemEvent e) {
@@ -106,6 +118,19 @@ public enum CEditorPreferences implements ICDoc {
((JCheckBox) e.getSource()).isSelected()); ((JCheckBox) e.getSource()).isSelected());
SEditorIO.setPref(EditorPreference.stats_deck, ((JCheckBox) e.getSource()).isSelected()); SEditorIO.setPref(EditorPreference.stats_deck, ((JCheckBox) e.getSource()).isSelected());
SEditorIO.savePreferences(); } }); SEditorIO.savePreferences(); } });
VEditorPreferences.SINGLETON_INSTANCE.getChbCardDisplayUnique().addItemListener(new ItemListener() {
@Override public void itemStateChanged(final ItemEvent e) {
ACEditorBase<?, ?> curEditor = CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController();
boolean wantUnique = ((JCheckBox) e.getSource()).isSelected();
if (curEditor != null) {
curEditor.getTableCatalog().setWantUnique(wantUnique);
curEditor.getTableCatalog().updateView(true);
curEditor.getTableDeck().setWantUnique(wantUnique);
curEditor.getTableDeck().updateView(true);
}
SEditorIO.setPref(EditorPreference.display_unique_only, wantUnique);
SEditorIO.savePreferences(); } });
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@@ -90,6 +90,9 @@ public final class CEditorQuest extends ACEditorBase<CardPrinted, Deck> {
final EditorTableView<CardPrinted> tblCatalog = new EditorTableView<CardPrinted>(false, CardPrinted.class); final EditorTableView<CardPrinted> tblCatalog = new EditorTableView<CardPrinted>(false, CardPrinted.class);
final EditorTableView<CardPrinted> tblDeck = new EditorTableView<CardPrinted>(false, CardPrinted.class); final EditorTableView<CardPrinted> tblDeck = new EditorTableView<CardPrinted>(false, CardPrinted.class);
tblCatalog.setAlwaysNonUnique(true);
tblDeck.setAlwaysNonUnique(true);
VCardCatalog.SINGLETON_INSTANCE.setTableView(tblCatalog.getTable()); VCardCatalog.SINGLETON_INSTANCE.setTableView(tblCatalog.getTable());
VCurrentDeck.SINGLETON_INSTANCE.setTableView(tblDeck.getTable()); VCurrentDeck.SINGLETON_INSTANCE.setTableView(tblDeck.getTable());

View File

@@ -98,6 +98,9 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
final EditorTableView<InventoryItem> tblCatalog = new EditorTableView<InventoryItem>(false, InventoryItem.class); final EditorTableView<InventoryItem> tblCatalog = new EditorTableView<InventoryItem>(false, InventoryItem.class);
final EditorTableView<InventoryItem> tblDeck = new EditorTableView<InventoryItem>(false, InventoryItem.class); final EditorTableView<InventoryItem> tblDeck = new EditorTableView<InventoryItem>(false, InventoryItem.class);
tblCatalog.setAlwaysNonUnique(true);
tblDeck.setAlwaysNonUnique(true);
VCardCatalog.SINGLETON_INSTANCE.setTableView(tblCatalog.getTable()); VCardCatalog.SINGLETON_INSTANCE.setTableView(tblCatalog.getTable());
VCurrentDeck.SINGLETON_INSTANCE.setTableView(tblDeck.getTable()); VCurrentDeck.SINGLETON_INSTANCE.setTableView(tblDeck.getTable());

View File

@@ -52,6 +52,7 @@ public final class EditorTableView<T extends InventoryItem> {
private final JTable table = new JTable(); private final JTable table = new JTable();
private Predicate<T> filter = null; private Predicate<T> filter = null;
private boolean wantUnique = false; private boolean wantUnique = false;
private boolean alwaysNonUnique = false;
private final Class<T> genericType; private final Class<T> genericType;
@@ -301,4 +302,44 @@ public final class EditorTableView<T extends InventoryItem> {
return this.pool; return this.pool;
} }
/**
*
* getWantUnique.
*
* @return true if the editor is in "unique card names only" mode.
*/
public boolean getWantUnique() {
return this.wantUnique;
}
/**
*
* setWantUnique
*
* @param unique if true, the editor will be set to the "unique card names only" mode.
*/
public void setWantUnique(boolean unique) {
this.wantUnique = this.alwaysNonUnique ? false : unique;
}
/**
*
* getAlwaysNonUnique
*
* @return if ture, this editor must always show non-unique cards (e.g. quest editor).
*/
public boolean getAlwaysNonUnique() {
return this.alwaysNonUnique;
}
/**
*
* setAlwaysNonUnique
*
* @param nonUniqueOnly if true, this editor must always show non-unique cards (e.g. quest editor).
*/
public void setAlwaysNonUnique(boolean nonUniqueOnly) {
this.alwaysNonUnique = nonUniqueOnly;
}
} }

View File

@@ -41,6 +41,10 @@ public enum VEditorPreferences implements IVDoc<CEditorPreferences> {
.text("Current Deck Columns").tooltip("Toggle columns in current deck panel") .text("Current Deck Columns").tooltip("Toggle columns in current deck panel")
.fontSize(12).build(); .fontSize(12).build();
private JLabel lblDisplay = new FLabel.Builder()
.text("Card Catalog Options").tooltip("Toggle card catalog display options")
.fontSize(12).build();
private JCheckBox chbCatalogColor = new FCheckBox("Color"); private JCheckBox chbCatalogColor = new FCheckBox("Color");
private JCheckBox chbCatalogRarity = new FCheckBox("Rarity"); private JCheckBox chbCatalogRarity = new FCheckBox("Rarity");
private JCheckBox chbCatalogCMC = new FCheckBox("CMC"); private JCheckBox chbCatalogCMC = new FCheckBox("CMC");
@@ -60,6 +64,8 @@ public enum VEditorPreferences implements IVDoc<CEditorPreferences> {
private JCheckBox chbDeckStats = new FCheckBox("Show stats in current deck"); private JCheckBox chbDeckStats = new FCheckBox("Show stats in current deck");
private JCheckBox chbCatalogStats = new FCheckBox("Show stats in card catalog"); private JCheckBox chbCatalogStats = new FCheckBox("Show stats in card catalog");
private JCheckBox chbCardDisplayUnique = new FCheckBox("Show unique cards only (only affects Constructed)");
private JPanel pnl = new JPanel(new MigLayout("insets 0, gap 0, wrap 2, ax center")); private JPanel pnl = new JPanel(new MigLayout("insets 0, gap 0, wrap 2, ax center"));
private JScrollPane scroller = new JScrollPane(pnl); private JScrollPane scroller = new JScrollPane(pnl);
@@ -68,6 +74,7 @@ public enum VEditorPreferences implements IVDoc<CEditorPreferences> {
lblStats.setBorder(new MatteBorder(0, 0, 1, 0, FSkin.getColor(FSkin.Colors.CLR_BORDERS))); lblStats.setBorder(new MatteBorder(0, 0, 1, 0, FSkin.getColor(FSkin.Colors.CLR_BORDERS)));
lblCatalog.setBorder(new MatteBorder(0, 0, 1, 0, FSkin.getColor(FSkin.Colors.CLR_BORDERS))); lblCatalog.setBorder(new MatteBorder(0, 0, 1, 0, FSkin.getColor(FSkin.Colors.CLR_BORDERS)));
lblDeck.setBorder(new MatteBorder(0, 0, 1, 0, FSkin.getColor(FSkin.Colors.CLR_BORDERS))); lblDeck.setBorder(new MatteBorder(0, 0, 1, 0, FSkin.getColor(FSkin.Colors.CLR_BORDERS)));
lblDisplay.setBorder(new MatteBorder(0, 0, 1, 0, FSkin.getColor(FSkin.Colors.CLR_BORDERS)));
chbCatalogColor.setFont(FSkin.getFont(12)); chbCatalogColor.setFont(FSkin.getFont(12));
chbCatalogRarity.setFont(FSkin.getFont(12)); chbCatalogRarity.setFont(FSkin.getFont(12));
@@ -85,12 +92,14 @@ public enum VEditorPreferences implements IVDoc<CEditorPreferences> {
chbDeckPower.setFont(FSkin.getFont(12)); chbDeckPower.setFont(FSkin.getFont(12));
chbDeckToughness.setFont(FSkin.getFont(12)); chbDeckToughness.setFont(FSkin.getFont(12));
chbDeckStats.setFont(FSkin.getFont(12)); chbDeckStats.setFont(FSkin.getFont(12));
chbCatalogStats.setFont(FSkin.getFont(12)); chbCatalogStats.setFont(FSkin.getFont(12));
chbDeckStats.setSelected(true); chbDeckStats.setSelected(true);
chbCatalogStats.setSelected(true); chbCatalogStats.setSelected(true);
chbCardDisplayUnique.setFont(FSkin.getFont(12));
chbCardDisplayUnique.setSelected(false);
pnl.add(lblStats, "h 25px!, gap 5px 5px 5px 5px, ax center, span 2 1"); pnl.add(lblStats, "h 25px!, gap 5px 5px 5px 5px, ax center, span 2 1");
pnl.add(chbCatalogStats, "h 25px!, gap 5px 5px 5px 5px, ax center, span 2 1"); pnl.add(chbCatalogStats, "h 25px!, gap 5px 5px 5px 5px, ax center, span 2 1");
pnl.add(chbDeckStats, "h 25px!, gap 5px 5px 5px 5px, ax center, span 2 1"); pnl.add(chbDeckStats, "h 25px!, gap 5px 5px 5px 5px, ax center, span 2 1");
@@ -112,7 +121,10 @@ public enum VEditorPreferences implements IVDoc<CEditorPreferences> {
pnl.add(chbDeckSet, constraints); pnl.add(chbDeckSet, constraints);
pnl.add(chbDeckPower, constraints); pnl.add(chbDeckPower, constraints);
pnl.add(chbDeckToughness, constraints); pnl.add(chbDeckToughness, constraints);
pnl.add(chbDeckAI, constraints); pnl.add(chbDeckAI, constraints + ", wrap");
pnl.add(lblDisplay, constraints + ", span 2 1");
pnl.add(chbCardDisplayUnique, "h 25px!, gap 5px 5px 5px 5px, ax center, span 2 1");
pnl.setOpaque(false); pnl.setOpaque(false);
scroller.setOpaque(false); scroller.setOpaque(false);
@@ -252,6 +264,11 @@ public enum VEditorPreferences implements IVDoc<CEditorPreferences> {
public JCheckBox getChbCatalogStats() { public JCheckBox getChbCatalogStats() {
return chbCatalogStats; return chbCatalogStats;
} }
/** @return {@link javax.swing.JCheckBox} */
public JCheckBox getChbCardDisplayUnique() {
return chbCardDisplayUnique;
}
//========== Other methods //========== Other methods
} }