Fixed "Decks" column in Card Shop. Added "Decks" column to Quest deck editor.

This commit is contained in:
Doublestrike
2012-05-26 08:19:00 +00:00
parent 6df7e78dc6
commit d7be84d489
7 changed files with 111 additions and 39 deletions

1
.gitattributes vendored
View File

@@ -11087,6 +11087,7 @@ res/pics_product/tournamentpacks/SHM.jpg -text
res/pics_product/tournamentpacks/TMP.jpg -text
res/pics_product/tournamentpacks/TSP.jpg -text
res/pics_product/tournamentpacks/USG.jpg -text
res/preferences/.project -text
res/preferences/editor.preferences -text
res/preferences/main.properties -text
res/product-images.txt -text

11
res/preferences/.project Normal file
View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>preferences</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

View File

@@ -2,31 +2,31 @@
<preferences type="editor">
<pref name="stats_catalog" value="true"></pref>
<pref name="stats_deck" value="true"></pref>
<col enumval="CAT_QUANTITY" identifier="Quantity" index="0" show="true" sortpriority="0" sortstate="NONE" width="75"></col>
<col enumval="CAT_NAME" identifier="Name" index="0" show="true" sortpriority="2" sortstate="ASC" width="79"></col>
<col enumval="CAT_COST" identifier="Cost" index="4" show="true" sortpriority="0" sortstate="NONE" width="71"></col>
<col enumval="CAT_COLOR" identifier="Color" index="1" show="true" sortpriority="0" sortstate="NONE" width="81"></col>
<col enumval="CAT_TYPE" identifier="Type" index="2" show="true" sortpriority="0" sortstate="ASC" width="88"></col>
<col enumval="CAT_POWER" identifier="Power" index="3" show="true" sortpriority="0" sortstate="NONE" width="58"></col>
<col enumval="CAT_TOUGHNESS" identifier="Toughness" index="5" show="true" sortpriority="1" sortstate="ASC" width="59"></col>
<col enumval="CAT_CMC" identifier="CMC" index="6" show="true" sortpriority="0" sortstate="NONE" width="58"></col>
<col enumval="CAT_QUANTITY" identifier="Quantity" index="0" show="true" sortpriority="1" sortstate="ASC" width="49"></col>
<col enumval="CAT_NAME" identifier="Name" index="7" show="true" sortpriority="3" sortstate="ASC" width="52"></col>
<col enumval="CAT_COST" identifier="Cost" index="4" show="true" sortpriority="0" sortstate="NONE" width="48"></col>
<col enumval="CAT_COLOR" identifier="Color" index="1" show="true" sortpriority="0" sortstate="NONE" width="54"></col>
<col enumval="CAT_TYPE" identifier="Type" index="2" show="true" sortpriority="0" sortstate="ASC" width="57"></col>
<col enumval="CAT_POWER" identifier="Power" index="3" show="true" sortpriority="0" sortstate="NONE" width="40"></col>
<col enumval="CAT_TOUGHNESS" identifier="Toughness" index="5" show="true" sortpriority="2" sortstate="ASC" width="40"></col>
<col enumval="CAT_CMC" identifier="CMC" index="6" show="true" sortpriority="0" sortstate="NONE" width="40"></col>
<col enumval="CAT_RARITY" identifier="Rarity" index="7" show="false" sortpriority="0" sortstate="ASC" width="75"></col>
<col enumval="CAT_SET" identifier="Set" index="9" show="false" sortpriority="0" sortstate="NONE" width="75"></col>
<col enumval="CAT_AI" identifier="AI" index="10" show="false" sortpriority="0" sortstate="NONE" width="75"></col>
<col enumval="CAT_NEW" identifier="New" index="8" show="true" sortpriority="0" sortstate="NONE" width="75"></col>
<col enumval="CAT_PURCHASE_PRICE" identifier="Purchase Price" index="10" show="true" sortpriority="0" sortstate="NONE" width="75"></col>
<col enumval="CAT_DECKS" identifier="Decks" index="9" show="true" sortpriority="0" sortstate="NONE" width="75"></col>
<col enumval="DECK_QUANTITY" identifier="Quantity" index="0" show="true" sortpriority="0" sortstate="NONE" width="47"></col>
<col enumval="DECK_NAME" identifier="Name" index="1" show="true" sortpriority="1" sortstate="ASC" width="107"></col>
<col enumval="DECK_COST" identifier="Cost" index="2" show="true" sortpriority="0" sortstate="NONE" width="42"></col>
<col enumval="DECK_COLOR" identifier="Color" index="5" show="true" sortpriority="0" sortstate="NONE" width="41"></col>
<col enumval="DECK_TYPE" identifier="Type" index="4" show="true" sortpriority="0" sortstate="NONE" width="41"></col>
<col enumval="DECK_POWER" identifier="Power" index="6" show="true" sortpriority="0" sortstate="NONE" width="40"></col>
<col enumval="DECK_TOUGHNESS" identifier="Toughness" index="7" show="true" sortpriority="0" sortstate="NONE" width="37"></col>
<col enumval="DECK_CMC" identifier="CMC" index="8" show="true" sortpriority="0" sortstate="NONE" width="40"></col>
<col enumval="DECK_RARITY" identifier="Rarity" index="9" show="true" sortpriority="0" sortstate="NONE" width="36"></col>
<col enumval="DECK_SET" identifier="Set" index="10" show="true" sortpriority="0" sortstate="NONE" width="35"></col>
<col enumval="DECK_AI" identifier="AI" index="3" show="true" sortpriority="0" sortstate="NONE" width="43"></col>
<col enumval="DECK_NEW" identifier="New" index="11" show="true" sortpriority="0" sortstate="NONE" width="75"></col>
<col enumval="DECK_SALE_PRICE" identifier="Sale Price" index="12" show="true" sortpriority="1" sortstate="ASC" width="75"></col>
<col enumval="CAT_NEW" identifier="New" index="8" show="true" sortpriority="0" sortstate="NONE" width="50"></col>
<col enumval="CAT_PURCHASE_PRICE" identifier="Purchase Price" index="9" show="true" sortpriority="0" sortstate="NONE" width="64"></col>
<col enumval="DECK_QUANTITY" identifier="Quantity" index="0" show="true" sortpriority="0" sortstate="NONE" width="32"></col>
<col enumval="DECK_NAME" identifier="Name" index="1" show="true" sortpriority="1" sortstate="ASC" width="62"></col>
<col enumval="DECK_COST" identifier="Cost" index="2" show="true" sortpriority="0" sortstate="NONE" width="29"></col>
<col enumval="DECK_COLOR" identifier="Color" index="5" show="true" sortpriority="0" sortstate="NONE" width="29"></col>
<col enumval="DECK_TYPE" identifier="Type" index="4" show="true" sortpriority="0" sortstate="NONE" width="29"></col>
<col enumval="DECK_POWER" identifier="Power" index="6" show="true" sortpriority="0" sortstate="NONE" width="28"></col>
<col enumval="DECK_TOUGHNESS" identifier="Toughness" index="7" show="true" sortpriority="0" sortstate="NONE" width="26"></col>
<col enumval="DECK_CMC" identifier="CMC" index="8" show="true" sortpriority="0" sortstate="NONE" width="28"></col>
<col enumval="DECK_RARITY" identifier="Rarity" index="9" show="true" sortpriority="0" sortstate="NONE" width="26"></col>
<col enumval="DECK_SET" identifier="Set" index="10" show="true" sortpriority="0" sortstate="NONE" width="25"></col>
<col enumval="DECK_AI" identifier="AI" index="3" show="true" sortpriority="0" sortstate="NONE" width="29"></col>
<col enumval="DECK_NEW" identifier="New" index="11" show="true" sortpriority="0" sortstate="NONE" width="46"></col>
<col enumval="DECK_SALE_PRICE" identifier="Sale Price" index="12" show="true" sortpriority="2" sortstate="ASC" width="60"></col>
<col enumval="DECK_DECKS" identifier="Decks" index="13" show="true" sortpriority="1" sortstate="DESC" width="45"></col>
</preferences>

View File

@@ -90,6 +90,24 @@ public class SEditorIO {
* @return TableColumnInfo<InventoryItem>
*/
public static TableColumnInfo<InventoryItem> getColumn(final ColumnName name0) {
/* final ColumnName[] vals = ColumnName.values();
boolean exists = false;
for (int i = 0; i < vals.length; i++) {
if (vals.equals(name0)) { exists = true; break; }
}
// Columns that are not in the enum must be created.
if (!exists) {
final TableColumnInfo<InventoryItem> col;
col = new TableColumnInfo<InventoryItem>();
col.setIdentifier(name0.toString());
col.setShowing(true);
col.setSortPriority(0);
col.setSortState(SortState.NONE);
col.setPreferredWidth(100);
COLS.put(name0, col);
}*/
return COLS.get(name0);
}
@@ -294,7 +312,9 @@ public class SEditorIO {
while (attributes.hasNext()) {
attribute = (Attribute) attributes.next();
if (attribute.getName().toString().equals(ColumnProperty.enumval.toString())) {
COLS.put(ColumnName.valueOf(attribute.getValue()), tempcol);
try { COLS.put(ColumnName.valueOf(attribute.getValue()), tempcol); }
catch (final Exception e) { }
tempcol.setEnumValue(attribute.getValue());
}
else if (attribute.getName().toString().equals(ColumnProperty.identifier.toString())) {

View File

@@ -18,7 +18,10 @@
package forge.gui.deckeditor.controllers;
// import java.awt.Font;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import forge.AllZone;
import forge.Constant;
@@ -37,6 +40,7 @@ import forge.item.InventoryItem;
import forge.item.ItemPool;
import forge.quest.QuestController;
import forge.util.closures.Lambda0;
import forge.util.closures.Lambda1;
//import forge.quest.data.QuestBoosterPack;
@@ -54,6 +58,25 @@ public final class CEditorQuest extends ACEditorBase<CardPrinted, Deck> {
private final QuestController questData;
private final DeckController<Deck> controller;
private Map<CardPrinted, Integer> decksUsingMyCards;
@SuppressWarnings("rawtypes")
private final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnDeckCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
@Override
public Comparable apply(final Entry<InventoryItem, Integer> from) {
final Integer iValue = CEditorQuest.this.decksUsingMyCards.get(from.getKey());
return iValue == null ? Integer.valueOf(0) : iValue;
}
};
private final Lambda1<Object, Entry<InventoryItem, Integer>> fnDeckGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
@Override
public Object apply(final Entry<InventoryItem, Integer> from) {
final Integer iValue = CEditorQuest.this.decksUsingMyCards.get(from.getKey());
return iValue == null ? "" : iValue.toString();
}
};
/**
* Child controller for quest deck editor UI.
* <br><br>
@@ -93,6 +116,19 @@ public final class CEditorQuest extends ACEditorBase<CardPrinted, Deck> {
this.questData.getCards().getCardpool().add(card);
}
// fills number of decks using each card
private Map<CardPrinted, Integer> countDecksForEachCard() {
final Map<CardPrinted, Integer> result = new HashMap<CardPrinted, Integer>();
for (final Deck deck : this.questData.getMyDecks()) {
for (final Entry<CardPrinted, Integer> e : deck.getMain()) {
final CardPrinted card = e.getKey();
final Integer amount = result.get(card);
result.put(card, Integer.valueOf(amount == null ? 1 : 1 + amount.intValue()));
}
}
return result;
}
//=========== Overridden from ACEditorBase
/* (non-Javadoc)
@@ -164,19 +200,23 @@ public final class CEditorQuest extends ACEditorBase<CardPrinted, Deck> {
final List<TableColumnInfo<InventoryItem>> columnsCatalog = SColumnUtil.getCatalogDefaultColumns();
final List<TableColumnInfo<InventoryItem>> columnsDeck = SColumnUtil.getDeckDefaultColumns();
this.decksUsingMyCards = this.countDecksForEachCard();
// Add "new" column in catalog and deck
columnsCatalog.add(SColumnUtil.getColumn(ColumnName.CAT_NEW));
columnsCatalog.get(columnsCatalog.size() - 1).setSortAndDisplayFunctions(
this.questData.getCards().getFnNewCompare(),
this.questData.getCards().getFnNewGet());
columnsDeck.add(SColumnUtil.getColumn(ColumnName.DECK_NEW));
columnsDeck.get(columnsDeck.size() - 1).setSortAndDisplayFunctions(
this.questData.getCards().getFnNewCompare(),
this.questData.getCards().getFnNewGet());
columnsDeck.add(SColumnUtil.getColumn(ColumnName.DECK_DECKS));
columnsDeck.get(columnsDeck.size() - 1).setSortAndDisplayFunctions(
this.fnDeckCompare, this.fnDeckGet);
this.getTableCatalog().setup(VCardCatalog.SINGLETON_INSTANCE, columnsCatalog);
this.getTableDeck().setup(VCurrentDeck.SINGLETON_INSTANCE, columnsDeck);

View File

@@ -106,10 +106,6 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
columnsCatalog.get(columnsCatalog.size() - 1).setSortAndDisplayFunctions(
this.fnPriceCompare, this.fnPriceGet);
columnsCatalog.add(SColumnUtil.getColumn(ColumnName.CAT_DECKS));
columnsCatalog.get(columnsCatalog.size() - 1).setSortAndDisplayFunctions(
this.fnDeckCompare, this.fnDeckGet);
columnsCatalog.add(SColumnUtil.getColumn(ColumnName.CAT_NEW));
columnsCatalog.get(columnsCatalog.size() - 1).setSortAndDisplayFunctions(
this.questData.getCards().getFnNewCompare(), this.questData.getCards().getFnNewGet());
@@ -122,6 +118,10 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
columnsDeck.get(columnsDeck.size() - 1).setSortAndDisplayFunctions(
this.questData.getCards().getFnNewCompare(), this.questData.getCards().getFnNewGet());
columnsDeck.add(SColumnUtil.getColumn(ColumnName.DECK_DECKS));
columnsDeck.get(columnsDeck.size() - 1).setSortAndDisplayFunctions(
this.fnDeckCompare, this.fnDeckGet);
// Setup with current column set
this.getTableCatalog().setup(VCardCatalog.SINGLETON_INSTANCE, columnsCatalog);
this.getTableDeck().setup(VCurrentDeck.SINGLETON_INSTANCE, columnsDeck);

View File

@@ -69,7 +69,6 @@ public final class SColumnUtil {
CAT_AI, /** */
CAT_NEW, /** */
CAT_PURCHASE_PRICE, /** */
CAT_DECKS, /** */
DECK_QUANTITY, /** */
DECK_NAME, /** */
DECK_COST, /** */
@@ -82,7 +81,8 @@ public final class SColumnUtil {
DECK_SET, /** */
DECK_AI, /** */
DECK_NEW, /** */
DECK_SALE_PRICE;
DECK_SALE_PRICE, /** */
DECK_DECKS;
}
/** Possible states of data sorting in a column: none, ascending, or descending. */
@@ -179,14 +179,14 @@ public final class SColumnUtil {
SColumnUtil.FN_AI_STATUS_COMPARE, SColumnUtil.FN_AI_STATUS_GET);
SColumnUtil.getColumn(ColumnName.CAT_COST).setCellRenderer(new ManaCostRenderer());
SColumnUtil.getColumn(ColumnName.CAT_POWER).setCellRenderer(new IntegerRenderer());
SColumnUtil.getColumn(ColumnName.CAT_TOUGHNESS).setCellRenderer(new IntegerRenderer());
SColumnUtil.getColumn(ColumnName.CAT_CMC).setCellRenderer(new IntegerRenderer());
//SColumnUtil.getColumn(ColumnName.CAT_POWER).setCellRenderer(new IntegerRenderer());
//SColumnUtil.getColumn(ColumnName.CAT_TOUGHNESS).setCellRenderer(new IntegerRenderer());
//SColumnUtil.getColumn(ColumnName.CAT_CMC).setCellRenderer(new IntegerRenderer());
SColumnUtil.getColumn(ColumnName.DECK_COST).setCellRenderer(new ManaCostRenderer());
SColumnUtil.getColumn(ColumnName.DECK_POWER).setCellRenderer(new IntegerRenderer());
SColumnUtil.getColumn(ColumnName.DECK_TOUGHNESS).setCellRenderer(new IntegerRenderer());
SColumnUtil.getColumn(ColumnName.DECK_CMC).setCellRenderer(new IntegerRenderer());
//SColumnUtil.getColumn(ColumnName.DECK_POWER).setCellRenderer(new IntegerRenderer());
//SColumnUtil.getColumn(ColumnName.DECK_TOUGHNESS).setCellRenderer(new IntegerRenderer());
//SColumnUtil.getColumn(ColumnName.DECK_CMC).setCellRenderer(new IntegerRenderer());
}
/**