Moving hard-coded text to res files

This commit is contained in:
churrufli
2019-06-21 00:41:06 +02:00
parent 181aa0f2ab
commit b91773f73f

View File

@@ -31,12 +31,170 @@ import forge.itemmanager.ItemColumnConfig.SortState;
import forge.limited.DraftRankCache; import forge.limited.DraftRankCache;
import forge.model.FModel; import forge.model.FModel;
import forge.util.Localizer; import forge.util.Localizer;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.Map.Entry; import java.util.Map.Entry;
public enum ColumnDef { public enum ColumnDef {
/**The column containing the inventory item name.*/
STRING("", "", 0, false, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return from.getKey() instanceof Comparable<?> ? (Comparable<?>)from.getKey() : from.getKey().getName();
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return from.getKey().toString();
}
}),
/**The name column.*/
NAME("lblName", "lblName", 180, false, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toSortableName(from.getKey().getName());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return from.getKey().getName();
}
}),
/**The column for sorting cards in collector order.*/
COLLECTOR_ORDER("lblCN", "ttCN", 20, false, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toCollectorPrefix(from.getKey());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return "";
}
}),
/**The type column.*/
TYPE("lblType", "ttType", 100, false, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toType(from.getKey());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toType(from.getKey());
}
}),
/**The mana cost column.*/
COST("lblCost", "ttCost", 70, true, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toManaCost(from.getKey());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toCardRules(from.getKey());
}
}),
/**The color column.*/
COLOR("lblColor", "ttColor", 46, true, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toColor(from.getKey());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toColor(from.getKey());
}
}),
/**The power column.*/
POWER("lblPower", "ttPower", 20, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toPower(from.getKey());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toPower(from.getKey());
}
}),
/**The toughness column.*/
TOUGHNESS("lblToughness", "ttToughness", 20, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toToughness(from.getKey());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toToughness(from.getKey());
}
}),
/**The converted mana cost column.*/
CMC("lblCMC", "ttCMC", 20, true, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toCMC(from.getKey());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toCMC(from.getKey());
}
}),
/**The rarity column.*/
RARITY("lblRarity", "lblRarity", 20, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toRarity(from.getKey());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toRarity(from.getKey());
}
}),
/**The set code column.*/
SET("lblSet", "lblSet", 38, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
InventoryItem i = from.getKey();
return i instanceof InventoryItemFromSet ? FModel.getMagicDb().getEditions()
.get(((InventoryItemFromSet) i).getEdition()) : CardEdition.UNKNOWN;
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
InventoryItem i = from.getKey();
return i instanceof InventoryItemFromSet ? ((InventoryItemFromSet) i).getEdition() : "n/a";
}
}),
/**The AI compatibility flag column*/
AI("lblAI", "lblAIStatus", 30, true, SortState.ASC, AI("lblAI", "lblAIStatus", 30, true, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() { new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override @Override
@@ -58,110 +216,80 @@ public enum ColumnDef {
return ai.getRemAIDecks() ? (ai.getRemRandomDecks() ? "AI ?" : "AI") return ai.getRemAIDecks() ? (ai.getRemRandomDecks() ? "AI ?" : "AI")
: (ai.getRemRandomDecks() ? "?" : ""); : (ai.getRemRandomDecks() ? "?" : "");
} }
})/**The AI compatibility flag column*/ }),
, /**The Draft ranking column.*/
CMC("lblCMC", "ttCMC", 20, true, SortState.ASC, RANKING("lblRanking", "lblDraftRanking", 50, true, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() { new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override @Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) { public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toCMC(from.getKey()); return toRanking(from.getKey(), false);
} }
}, },
new Function<Entry<? extends InventoryItem, Integer>, Object>() { new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override @Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) { public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toCMC(from.getKey()); return toRanking(from.getKey(), true);
} }
})/**The converted mana cost column.*/ }),
, /**The quantity column.*/
QUANTITY("lblQty", "lblQuantity", 25, true, SortState.ASC,
COLLECTOR_ORDER("lblCN", "ttCN", 20, false, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() { new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override @Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) { public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toCollectorPrefix(from.getKey()); return from.getValue();
} }
}, },
new Function<Entry<? extends InventoryItem, Integer>, Object>() { new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override @Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) { public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return ""; return from.getValue();
} }
})/**The column for sorting cards in collector order.*/ }),
, /**The quantity in deck column.*/
COLOR("lblColor", "ttColor", 46, true, SortState.ASC, DECK_QUANTITY("lblQuantity", "lblQuantity", 50, true, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() { new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override @Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) { public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toColor(from.getKey()); return from.getValue();
} }
}, },
new Function<Entry<? extends InventoryItem, Integer>, Object>() { new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override @Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) { public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toColor(from.getKey()); return from.getValue();
} }
})/**The color column.*/ }),
, /**The new inventory flag column.*/
COST("lblCost", "ttCost", 70, true, SortState.ASC, NEW("lblNew", "lblNew", 30, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() { null, null), //functions will be set later
@Override /**The price column.*/
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) { PRICE("lblPrice", "ttPrice", 35, true, SortState.DESC,
return toManaCost(from.getKey()); null, null),
} /**The quantity owned column.*/
}, OWNED("lblOwned", "lblOwned", 20, true, SortState.ASC,
new Function<Entry<? extends InventoryItem, Integer>, Object>() { null, null),
@Override /**The deck name column.*/
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toCardRules(from.getKey());
}
})/**The mana cost column.*/
,
DECKS("lblDecks", "lblDecks", 20, true, SortState.ASC, DECKS("lblDecks", "lblDecks", 20, true, SortState.ASC,
null, null)/**The deck name column.*/ null, null),
, /**The favorite flag column.*/
DECK_ACTIONS("", "lblDeleteEdit", 40, true, SortState.DESC, FAVORITE("", "ttFavorite", 18, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() { new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override @Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) { public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return 0; IPaperCard card = toCard(from.getKey());
if (card == null) {
return -1;
}
return CardPreferences.getPrefs(card).getStarCount();
} }
}, },
new Function<Entry<? extends InventoryItem, Integer>, Object>() { new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override @Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) { public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toDeck(from.getKey()); return toCard(from.getKey());
} }
})/**The edit/delete deck column.*/ }),
, /**The favorite deck flag column.*/
DECK_COLOR("lblColor", "lblColor", 70, true, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toDeckColor(from.getKey());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toDeckColor(from.getKey());
}
})/**The deck color column.*/
,
DECK_EDITION("lblSet", "lblSetEdition", 38, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toDeck(from.getKey()).getEdition();
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toDeck(from.getKey()).getEdition().getCode();
}
})/**The deck edition column, a mystery to us all.*/
,
DECK_FAVORITE("", "ttFavorite", 18, true, SortState.DESC, DECK_FAVORITE("", "ttFavorite", 18, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() { new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override @Override
@@ -178,8 +306,22 @@ public enum ColumnDef {
public Object apply(final Entry<? extends InventoryItem, Integer> from) { public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toDeck(from.getKey()); return toDeck(from.getKey());
} }
})/**The favorite deck flag column.*/ }),
, /**The edit/delete deck column.*/
DECK_ACTIONS("", "lblDeleteEdit", 40, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return 0;
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toDeck(from.getKey());
}
}),
/**The deck folder column.*/
DECK_FOLDER("lblFolder", "lblFolder", 80, false, SortState.ASC, DECK_FOLDER("lblFolder", "lblFolder", 80, false, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() { new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override @Override
@@ -192,8 +334,22 @@ public enum ColumnDef {
public Object apply(final Entry<? extends InventoryItem, Integer> from) { public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toDeckFolder(from.getKey()); return toDeckFolder(from.getKey());
} }
})/**The deck folder column.*/ }),
, /**The deck color column.*/
DECK_COLOR("lblColor", "ttColor", 70, true, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toDeckColor(from.getKey());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toDeckColor(from.getKey());
}
}),
/**The deck format column.*/
DECK_FORMAT("lblFormat", "ttFormats", 60, false, SortState.DESC, DECK_FORMAT("lblFormat", "ttFormats", 60, false, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() { new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override @Override
@@ -221,8 +377,22 @@ public enum ColumnDef {
} }
return deck.getFormatsString(); return deck.getFormatsString();
} }
})/**The deck format column.*/ }),
, /**The deck edition column, a mystery to us all.*/
DECK_EDITION("lblSet", "lblSetEdition", 38, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toDeck(from.getKey()).getEdition();
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toDeck(from.getKey()).getEdition().getCode();
}
}),
/**The main library size column.*/
DECK_MAIN("lblMain", "ttMain", 30, true, SortState.ASC, DECK_MAIN("lblMain", "ttMain", 30, true, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() { new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override @Override
@@ -235,22 +405,8 @@ public enum ColumnDef {
public Object apply(final Entry<? extends InventoryItem, Integer> from) { public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toDeck(from.getKey()).getMainSize(); return toDeck(from.getKey()).getMainSize();
} }
})/**The main library size column.*/ }),
, /**The sideboard size column.*/
DECK_QUANTITY("lblQty", "lblQuantity", 50, true, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return from.getValue();
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return from.getValue();
}
})/**The quantity in deck column.*/
,
DECK_SIDE("lblSide", "lblSideboard", 30, true, SortState.ASC, DECK_SIDE("lblSide", "lblSideboard", 30, true, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() { new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override @Override
@@ -263,169 +419,11 @@ public enum ColumnDef {
public Object apply(final Entry<? extends InventoryItem, Integer> from) { public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toDeck(from.getKey()).getSideSize(); return toDeck(from.getKey()).getSideSize();
} }
})/**The sideboard size column.*/ });
,
FAVORITE("", "ttFavorite", 18, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
IPaperCard card = toCard(from.getKey());
if (card == null) {
return -1;
}
return CardPreferences.getPrefs(card).getStarCount();
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toCard(from.getKey());
}
})/**The favorite flag column.*/
,
NAME("lblName", "lblName", 180, false, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toSortableName(from.getKey().getName());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return from.getKey().getName();
}
})/**The name column.*/
,
NEW("lblNew", "lblNew", 30, true, SortState.DESC,
null, null)/**The new inventory flag column.*/
, //functions will be set later
OWNED("lblOwned", "lblOwned", 20, true, SortState.ASC,
null, null)/**The quantity owned column.*/
,
POWER("lblPower", "ttPower", 20, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toPower(from.getKey());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toPower(from.getKey());
}
})/**The power column.*/
,
PRICE("lblPrice", "ttPrice", 35, true, SortState.DESC,
null, null)/**The price column.*/
,
QUANTITY("lblQty", "lblQuantity", 25, true, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return from.getValue();
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return from.getValue();
}
})/**The quantity column.*/
,
RANKING("lblRanking", "lblDraftRanking", 50, true, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toRanking(from.getKey(), false);
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toRanking(from.getKey(), true);
}
})/**The Draft ranking column.*/
,
RARITY("lblRarity", "lblRarity", 20, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toRarity(from.getKey());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toRarity(from.getKey());
}
})/**The rarity column.*/
,
SET("lblSet", "lblSet", 38, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
InventoryItem i = from.getKey();
return i instanceof InventoryItemFromSet ? FModel.getMagicDb().getEditions()
.get(((InventoryItemFromSet) i).getEdition()) : CardEdition.UNKNOWN;
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
InventoryItem i = from.getKey();
return i instanceof InventoryItemFromSet ? ((InventoryItemFromSet) i).getEdition() : "n/a";
}
})/**The set code column.*/
,
STRING("", "", 0, false, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return from.getKey() instanceof Comparable<?> ? (Comparable<?>) from.getKey() : from.getKey().getName();
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return from.getKey().toString();
}
})/**The column containing the inventory item name.*/
,
TOUGHNESS("lblToughness", "ttToughness", 20, true, SortState.DESC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toToughness(from.getKey());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toToughness(from.getKey());
}
})/**The toughness column.*/
,
TYPE("lblType", "ttType", 100, false, SortState.ASC,
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
@Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
return toType(from.getKey());
}
},
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
@Override
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
return toType(from.getKey());
}
})/**The type column.*/
;
ColumnDef(String shortName0, String longName0, int preferredWidth0, boolean isWidthFixed0, SortState sortState0, ColumnDef(String shortName0, String longName0, int preferredWidth0, boolean isWidthFixed0, SortState sortState0,
Function<Entry<InventoryItem, Integer>, Comparable<?>> fnSort0, Function<Entry<InventoryItem, Integer>, Comparable<?>> fnSort0,
Function<Entry<? extends InventoryItem, Integer>, Object> fnDisplay0) { Function<Entry<? extends InventoryItem, Integer>, Object> fnDisplay0) {
final Localizer localizer = Localizer.getInstance(); final Localizer localizer = Localizer.getInstance();
if (shortName0 != null && !shortName0.isEmpty()) { this.shortName = localizer.getMessage(shortName0);} else {this.shortName = shortName0;} if (shortName0 != null && !shortName0.isEmpty()) { this.shortName = localizer.getMessage(shortName0);} else {this.shortName = shortName0;}
@@ -449,7 +447,6 @@ public enum ColumnDef {
public String toString() { public String toString() {
return this.longName; return this.longName;
} }
/** /**
*Converts a card name to a sortable name. *Converts a card name to a sortable name.
* Trim leading quotes, then move article last, then replace characters. * Trim leading quotes, then move article last, then replace characters.
@@ -498,11 +495,9 @@ public enum ColumnDef {
private static IPaperCard toCard(final InventoryItem i) { private static IPaperCard toCard(final InventoryItem i) {
return i instanceof IPaperCard ? ((IPaperCard) i) : null; return i instanceof IPaperCard ? ((IPaperCard) i) : null;
} }
private static ManaCost toManaCost(final InventoryItem i) { private static ManaCost toManaCost(final InventoryItem i) {
return i instanceof IPaperCard ? ((IPaperCard) i).getRules().getManaCost() : ManaCost.NO_COST; return i instanceof IPaperCard ? ((IPaperCard) i).getRules().getManaCost() : ManaCost.NO_COST;
} }
private static CardRules toCardRules(final InventoryItem i) { private static CardRules toCardRules(final InventoryItem i) {
return i instanceof IPaperCard ? ((IPaperCard) i).getRules() : null; return i instanceof IPaperCard ? ((IPaperCard) i).getRules() : null;
} }
@@ -553,11 +548,9 @@ public enum ColumnDef {
private static DeckProxy toDeck(final InventoryItem i) { private static DeckProxy toDeck(final InventoryItem i) {
return i instanceof DeckProxy ? ((DeckProxy) i) : null; return i instanceof DeckProxy ? ((DeckProxy) i) : null;
} }
private static ColorSet toDeckColor(final InventoryItem i) { private static ColorSet toDeckColor(final InventoryItem i) {
return i instanceof DeckProxy ? ((DeckProxy) i).getColor() : null; return i instanceof DeckProxy ? ((DeckProxy) i).getColor() : null;
} }
private static String toDeckFolder(final InventoryItem i) { private static String toDeckFolder(final InventoryItem i) {
return i instanceof DeckProxy ? ((DeckProxy) i).getPath() + "/" : null; return i instanceof DeckProxy ? ((DeckProxy) i).getPath() + "/" : null;
} }
@@ -588,7 +581,7 @@ public enum ColumnDef {
@param i A paper card. @param i A paper card.
@return Part of a sortable numeric string.*/ @return Part of a sortable numeric string.*/
private static String toArtifactsWithColorlessCostsLast(final InventoryItem i) { private static String toArtifactsWithColorlessCostsLast(final InventoryItem i) {
ManaCost manaCost = ((IPaperCard) i).getRules().getManaCost(); forge.card.mana.ManaCost manaCost = ((IPaperCard) i).getRules().getManaCost();
return !(((IPaperCard) i).getRules().getType().isArtifact() && (toColor(i).isColorless() || return !(((IPaperCard) i).getRules().getType().isArtifact() && (toColor(i).isColorless() ||
//If it isn't colorless, see if it can be paid with only white, only blue, only black. //If it isn't colorless, see if it can be paid with only white, only blue, only black.
@@ -636,7 +629,7 @@ public enum ColumnDef {
@param i A paper card. @param i A paper card.
@return Part of a sortable numeric string.*/ @return Part of a sortable numeric string.*/
private static String toGoldFirst(final InventoryItem i) { private static String toGoldFirst(final InventoryItem i) {
ManaCost manaCost = ((IPaperCard) i).getRules().getManaCost(); forge.card.mana.ManaCost manaCost = ((IPaperCard) i).getRules().getManaCost();
return !(manaCost.canBePaidWithAvaliable(MagicColor.WHITE) | manaCost.canBePaidWithAvaliable(MagicColor.BLUE) | return !(manaCost.canBePaidWithAvaliable(MagicColor.WHITE) | manaCost.canBePaidWithAvaliable(MagicColor.BLUE) |
manaCost.canBePaidWithAvaliable(MagicColor.BLACK) | manaCost.canBePaidWithAvaliable(MagicColor.RED) | manaCost.canBePaidWithAvaliable(MagicColor.BLACK) | manaCost.canBePaidWithAvaliable(MagicColor.RED) |
@@ -652,8 +645,8 @@ public enum ColumnDef {
//This method serves as an entry point only, separating the two card parts for convenience. //This method serves as an entry point only, separating the two card parts for convenience.
private static String toSplitCardSort(final InventoryItem i) { private static String toSplitCardSort(final InventoryItem i) {
CardRules rules = ((IPaperCard) i).getRules(); CardRules rules = ((IPaperCard) i).getRules();
ICardFace mainPart = rules.getMainPart(); forge.card.ICardFace mainPart = rules.getMainPart();
ICardFace otherPart = rules.getOtherPart(); forge.card.ICardFace otherPart = rules.getOtherPart();
return toSplitSort(mainPart, otherPart); return toSplitSort(mainPart, otherPart);
} }