mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Support changing preferred art for cards in catalog
Support adding and removing catalog cards from favorites Only show unique cards in Catalog by default
This commit is contained in:
@@ -45,6 +45,10 @@ public class CardPreferences {
|
||||
final Element el = (Element)cards.item(i);
|
||||
allPrefs.put(el.getAttribute("name"), prefs);
|
||||
prefs.starCount = Integer.parseInt(el.getAttribute("stars"));
|
||||
prefs.preferredArt = el.getAttribute("art");
|
||||
if (prefs.preferredArt.length() == 0) {
|
||||
prefs.preferredArt = null; //don't store empty string
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
@@ -67,10 +71,16 @@ public class CardPreferences {
|
||||
document.appendChild(root);
|
||||
|
||||
for (Map.Entry<String, CardPreferences> entry : allPrefs.entrySet()) {
|
||||
if (entry.getValue().starCount > 0) {
|
||||
CardPreferences prefs = entry.getValue();
|
||||
if (prefs.starCount > 0 || prefs.preferredArt != null) {
|
||||
Element card = document.createElement("card");
|
||||
card.setAttribute("name", entry.getKey());
|
||||
card.setAttribute("stars", String.valueOf(entry.getValue().starCount));
|
||||
if (prefs.starCount > 0) {
|
||||
card.setAttribute("stars", String.valueOf(prefs.starCount));
|
||||
}
|
||||
if (prefs.preferredArt != null) {
|
||||
card.setAttribute("art", prefs.preferredArt);
|
||||
}
|
||||
root.appendChild(card);
|
||||
}
|
||||
}
|
||||
@@ -82,15 +92,24 @@ public class CardPreferences {
|
||||
}
|
||||
|
||||
private int starCount;
|
||||
private String preferredArt;
|
||||
|
||||
private CardPreferences() {
|
||||
}
|
||||
|
||||
public int getStarCount() {
|
||||
return this.starCount;
|
||||
return starCount;
|
||||
}
|
||||
|
||||
public void setStarCount(int starCount0) {
|
||||
this.starCount = starCount0;
|
||||
starCount = starCount0;
|
||||
}
|
||||
|
||||
public String getPreferredArt() {
|
||||
return preferredArt;
|
||||
}
|
||||
|
||||
public void setPreferredArt(String preferredArt0) {
|
||||
preferredArt = preferredArt0;
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import org.w3c.dom.NodeList;
|
||||
public enum ItemManagerConfig {
|
||||
STRING_ONLY(SColumnUtil.getStringColumn(), false, false, true,
|
||||
null, null, 1, 0),
|
||||
CARD_CATALOG(SColumnUtil.getCatalogDefaultColumns(true), true, false, false,
|
||||
CARD_CATALOG(SColumnUtil.getCatalogDefaultColumns(true), true, true, false,
|
||||
null, null, 4, 0),
|
||||
DECK_EDITOR(SColumnUtil.getDeckEditorDefaultColumns(), false, false, true,
|
||||
GroupDef.DEFAULT, ColumnDef.CMC, 4, 1),
|
||||
|
||||
@@ -124,6 +124,15 @@ public final class ItemManagerModel<T extends InventoryItem> {
|
||||
}
|
||||
}
|
||||
|
||||
public void replaceAll(final T item0, final T replacement0) {
|
||||
int count = this.data.count(item0);
|
||||
if (count > 0) {
|
||||
this.data.removeAll(item0);
|
||||
this.data.add(replacement0, count);
|
||||
isListInSync = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a item to the model.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user