add full catalog view to spell shop so players can compare their libraries to the full list of available cards; this way they can determine how close they are to completing a set

This commit is contained in:
myk
2013-01-31 03:38:32 +00:00
parent fd850d465a
commit 4dddfaa8c6
3 changed files with 58 additions and 14 deletions

View File

@@ -36,10 +36,10 @@ public enum VDeckEditorUI implements IVTopLevelUI {
@Override @Override
public Void doInBackground() { public Void doInBackground() {
SLayoutIO.loadLayout(null); SLayoutIO.loadLayout(null);
CCardCatalog.SINGLETON_INSTANCE.applyCurrentFilter();
return null; return null;
} }
}; };
CCardCatalog.SINGLETON_INSTANCE.applyCurrentFilter();
w.execute(); w.execute();
} }
} }

View File

@@ -29,6 +29,7 @@ import javax.swing.JOptionPane;
import com.google.common.base.Function; import com.google.common.base.Function;
import forge.Command;
import forge.Singletons; import forge.Singletons;
import forge.deck.Deck; import forge.deck.Deck;
import forge.deck.DeckBase; import forge.deck.DeckBase;
@@ -45,6 +46,7 @@ import forge.gui.home.quest.CSubmenuQuestDecks;
import forge.gui.toolbox.FLabel; import forge.gui.toolbox.FLabel;
import forge.gui.toolbox.FSkin; import forge.gui.toolbox.FSkin;
import forge.item.BoosterPack; import forge.item.BoosterPack;
import forge.item.CardDb;
import forge.item.CardPrinted; import forge.item.CardPrinted;
import forge.item.FatPack; import forge.item.FatPack;
import forge.item.InventoryItem; import forge.item.InventoryItem;
@@ -68,13 +70,29 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
private final JLabel creditsLabel = new FLabel.Builder() private final JLabel creditsLabel = new FLabel.Builder()
.icon(FSkin.getIcon(FSkin.QuestIcons.ICO_COINSTACK)) .icon(FSkin.getIcon(FSkin.QuestIcons.ICO_COINSTACK))
.fontSize(15).build(); .fontSize(15).build();
// TODO: move these to the view where they belong
private final JLabel sellPercentageLabel = new FLabel.Builder().text("0") private final JLabel sellPercentageLabel = new FLabel.Builder().text("0")
.fontSize(11) .fontSize(11)
.build(); .build();
@SuppressWarnings("serial")
private final JLabel fullCatalogToggle = new FLabel.Builder().text("See full catalog")
.fontSize(14).hoverable(true).cmdClick(new Command() {
@Override
public void execute() {
toggleFullCatalog();
}
})
.build();
private double multiplier; private double multiplier;
private final QuestController questData; private final QuestController questData;
private ItemPoolView<InventoryItem> cardsForSale;
private final ItemPool<InventoryItem> fullCatalogCards =
ItemPool.createFrom(CardDb.instance().getAllTraditionalCards(), InventoryItem.class);
private boolean showingFullCatalog = false;
// get pricelist: // get pricelist:
private final ReadPriceList r = new ReadPriceList(); private final ReadPriceList r = new ReadPriceList();
private final Map<String, Integer> mapPrices = this.r.getPriceList(); private final Map<String, Integer> mapPrices = this.r.getPriceList();
@@ -108,11 +126,22 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
this.setTableDeck(tblDeck); this.setTableDeck(tblDeck);
} }
/** private void toggleFullCatalog() {
* <p> showingFullCatalog = !showingFullCatalog;
* setup.
* </p> if (showingFullCatalog) {
*/ this.getTableCatalog().setDeck(fullCatalogCards);
VCardCatalog.SINGLETON_INSTANCE.getBtnAdd().setEnabled(false);
VCurrentDeck.SINGLETON_INSTANCE.getBtnRemove().setEnabled(false);
fullCatalogToggle.setText("Go back to spell shop");
} else {
this.getTableCatalog().setDeck(cardsForSale);
VCardCatalog.SINGLETON_INSTANCE.getBtnAdd().setEnabled(true);
VCurrentDeck.SINGLETON_INSTANCE.getBtnRemove().setEnabled(true);
fullCatalogToggle.setText("See full catalog");
}
}
private void setup() { private void setup() {
final List<TableColumnInfo<InventoryItem>> columnsCatalog = SColumnUtil.getCatalogDefaultColumns(); final List<TableColumnInfo<InventoryItem>> columnsCatalog = SColumnUtil.getCatalogDefaultColumns();
final List<TableColumnInfo<InventoryItem>> columnsDeck = SColumnUtil.getDeckDefaultColumns(); final List<TableColumnInfo<InventoryItem>> columnsDeck = SColumnUtil.getDeckDefaultColumns();
@@ -259,6 +288,11 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
*/ */
@Override @Override
public void addCard() { public void addCard() {
if (showingFullCatalog) {
// no "buying" from the full catalog
return;
}
final InventoryItem item = this.getTableCatalog().getSelectedCard(); final InventoryItem item = this.getTableCatalog().getSelectedCard();
if (item == null) { if (item == null) {
return; return;
@@ -319,6 +353,10 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
*/ */
@Override @Override
public void removeCard() { public void removeCard() {
if (showingFullCatalog) {
// no "selling" to the full catalog
return;
}
final InventoryItem item = this.getTableDeck().getSelectedCard(); final InventoryItem item = this.getTableDeck().getSelectedCard();
if ((item == null) || !(item instanceof CardPrinted)) { if ((item == null) || !(item instanceof CardPrinted)) {
return; return;
@@ -366,17 +404,17 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
this.multiplier = this.questData.getCards().getSellMultiplier(); this.multiplier = this.questData.getCards().getSellMultiplier();
ItemPoolView<InventoryItem> forSale = this.questData.getCards().getShopList(); cardsForSale = this.questData.getCards().getShopList();
if (forSale.isEmpty()) { if (cardsForSale.isEmpty()) {
this.questData.getCards().generateCardsInShop(); this.questData.getCards().generateCardsInShop();
forSale = this.questData.getCards().getShopList(); cardsForSale = this.questData.getCards().getShopList();
} }
// newCardsList = questData.getCards().getNewCards(); // newCardsList = questData.getCards().getNewCards();
final ItemPool<InventoryItem> ownedItems = new ItemPool<InventoryItem>(InventoryItem.class); final ItemPool<InventoryItem> ownedItems = new ItemPool<InventoryItem>(InventoryItem.class);
ownedItems.addAll(this.questData.getCards().getCardpool().getView()); ownedItems.addAll(this.questData.getCards().getCardpool().getView());
this.getTableCatalog().setDeck(forSale); this.getTableCatalog().setDeck(cardsForSale);
this.getTableDeck().setDeck(ownedItems); this.getTableDeck().setDeck(ownedItems);
VCurrentDeck.SINGLETON_INSTANCE.getPnlRemButtons().remove(VCurrentDeck.SINGLETON_INSTANCE.getBtnRemove4()); VCurrentDeck.SINGLETON_INSTANCE.getPnlRemButtons().remove(VCurrentDeck.SINGLETON_INSTANCE.getBtnRemove4());
@@ -392,6 +430,7 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
maxSellingPrice = String.format("Maximum selling price is %d credits.", maxSellPrice); maxSellingPrice = String.format("Maximum selling price is %d credits.", maxSellPrice);
} }
VCardCatalog.SINGLETON_INSTANCE.getPnlAddButtons().remove(VCardCatalog.SINGLETON_INSTANCE.getBtnAdd4()); VCardCatalog.SINGLETON_INSTANCE.getPnlAddButtons().remove(VCardCatalog.SINGLETON_INSTANCE.getBtnAdd4());
VCardCatalog.SINGLETON_INSTANCE.getPnlAddButtons().add(fullCatalogToggle, 0);
VCardCatalog.SINGLETON_INSTANCE.getPnlAddButtons().add(sellPercentageLabel); VCardCatalog.SINGLETON_INSTANCE.getPnlAddButtons().add(sellPercentageLabel);
this.sellPercentageLabel.setText("<html>Selling cards at " + formatter.format(multiPercent) this.sellPercentageLabel.setText("<html>Selling cards at " + formatter.format(multiPercent)
+ "% of their value.<br>" + maxSellingPrice + "</html>"); + "% of their value.<br>" + maxSellingPrice + "</html>");
@@ -402,11 +441,16 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
*/ */
@Override @Override
public boolean exit() { public boolean exit() {
if (showingFullCatalog) {
toggleFullCatalog();
}
Singletons.getModel().getQuest().save(); Singletons.getModel().getQuest().save();
CSubmenuQuestDecks.SINGLETON_INSTANCE.update(); CSubmenuQuestDecks.SINGLETON_INSTANCE.update();
// undo Card Shop Specifics // undo Card Shop Specifics
VCardCatalog.SINGLETON_INSTANCE.getPnlAddButtons().remove(sellPercentageLabel); VCardCatalog.SINGLETON_INSTANCE.getPnlAddButtons().remove(sellPercentageLabel);
VCardCatalog.SINGLETON_INSTANCE.getPnlAddButtons().remove(fullCatalogToggle);
VCardCatalog.SINGLETON_INSTANCE.getPnlAddButtons().add(VCardCatalog.SINGLETON_INSTANCE.getBtnAdd4()); VCardCatalog.SINGLETON_INSTANCE.getPnlAddButtons().add(VCardCatalog.SINGLETON_INSTANCE.getBtnAdd4());
VCurrentDeck.SINGLETON_INSTANCE.getPnlRemButtons().remove(creditsLabel); VCurrentDeck.SINGLETON_INSTANCE.getPnlRemButtons().remove(creditsLabel);

View File

@@ -187,8 +187,8 @@ public enum VCardCatalog implements IVDoc<CCardCatalog>, ITableContainer {
JPanel parentBody = parentCell.getBody(); JPanel parentBody = parentCell.getBody();
parentBody.setLayout(new MigLayout("insets 0, gap 0, wrap, hidemode 3")); parentBody.setLayout(new MigLayout("insets 0, gap 0, wrap, hidemode 3"));
parentBody.add(pnlHeader, "w 98%!, h 30px!, gap 1% 1% 0 0"); parentBody.add(pnlHeader, "w 98%!, h 30px!, gap 1% 1% 0 0");
parentBody.add(pnlStats, "w 96%, h 50px!, gap 2% 0 1% 1%"); parentBody.add(pnlStats, "w 96%, h 50px!, gap 1% 1% 0 0");
parentBody.add(pnlAddButtons, "w 96%!, gapleft 1%"); parentBody.add(pnlAddButtons, "w 96%!, gap 1% 1% 1% 1%");
parentBody.add(pnlSearch, "w 96%, gapleft 1%"); parentBody.add(pnlSearch, "w 96%, gapleft 1%");
parentBody.add(pnlRestrictions, "w 96%, gapleft 1%, gapright push"); parentBody.add(pnlRestrictions, "w 96%, gapleft 1%, gapright push");
parentBody.add(scroller, "w 98%!, h 100% - 35px, gap 1% 0 0 1%"); parentBody.add(scroller, "w 98%!, h 100% - 35px, gap 1% 0 0 1%");