mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Fix so switching group by options retains all groups being collapsed
Add option to group by rarity
This commit is contained in:
@@ -76,7 +76,7 @@ public enum GroupDef {
|
||||
return -1;
|
||||
}
|
||||
}),
|
||||
CARD_TYPE("Card Type",
|
||||
CARD_TYPE("Type",
|
||||
new String[] { "Creatures", "Artifacts", "Enchantments", "Planeswalkers", "Instants", "Sorceries", "Lands" },
|
||||
new Function<Integer, ColumnDef>() {
|
||||
@Override
|
||||
@@ -116,6 +116,36 @@ public enum GroupDef {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}),
|
||||
CARD_RARITY("Rarity",
|
||||
new String[] { "Mythic Rares", "Rares", "Uncommons", "Commons", "Basic Lands" },
|
||||
new Function<Integer, ColumnDef>() {
|
||||
@Override
|
||||
public ColumnDef apply(final Integer groupIndex) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
new Function<InventoryItem, Integer>() {
|
||||
@Override
|
||||
public Integer apply(final InventoryItem item) {
|
||||
if (item instanceof PaperCard) {
|
||||
switch (((PaperCard) item).getRarity()) {
|
||||
case MythicRare:
|
||||
return 0;
|
||||
case Rare:
|
||||
return 1;
|
||||
case Uncommon:
|
||||
return 2;
|
||||
case Common:
|
||||
return 3;
|
||||
case BasicLand:
|
||||
return 4;
|
||||
default:
|
||||
return -1; //show Special and Unknown in "Other" group
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
});
|
||||
|
||||
GroupDef(String name0, String[] groups0, Function<Integer, ColumnDef> fnGetPileByOverride0, Function<InventoryItem, Integer> fnGroupItem0) {
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
private static final int MIN_COLUMN_COUNT = 1;
|
||||
private static final int MAX_COLUMN_COUNT = 10;
|
||||
|
||||
private static final GroupDef[] CARD_GROUPBY_OPTIONS = { GroupDef.CREATURE_SPELL_LAND, GroupDef.CARD_TYPE, GroupDef.COLOR, GroupDef.COLOR_IDENTITY };
|
||||
private static final GroupDef[] CARD_GROUPBY_OPTIONS = { GroupDef.CREATURE_SPELL_LAND, GroupDef.CARD_TYPE, GroupDef.COLOR, GroupDef.COLOR_IDENTITY, GroupDef.CARD_RARITY };
|
||||
private static final GroupDef[] DECK_GROUPBY_OPTIONS = { GroupDef.COLOR, GroupDef.COLOR_IDENTITY };
|
||||
private static final ColumnDef[] CARD_PILEBY_OPTIONS = { ColumnDef.CMC, ColumnDef.COLOR, ColumnDef.NAME, ColumnDef.COST, ColumnDef.TYPE, ColumnDef.RARITY, ColumnDef.SET };
|
||||
private static final ColumnDef[] DECK_PILEBY_OPTIONS = { ColumnDef.DECK_COLOR, ColumnDef.DECK_FOLDER, ColumnDef.NAME, ColumnDef.DECK_FORMAT, ColumnDef.DECK_EDITION };
|
||||
@@ -370,13 +370,20 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
|
||||
if (groupBy == null) {
|
||||
groups.add(new Group(""));
|
||||
btnExpandCollapseAll.updateIsAllCollapsed();
|
||||
}
|
||||
else {
|
||||
for (String groupName : groupBy.getGroups()) {
|
||||
groups.add(new Group(groupName));
|
||||
}
|
||||
|
||||
//collapse all groups by default if all previous groups were collapsed
|
||||
if (btnExpandCollapseAll.isAllCollapsed) {
|
||||
for (Group group : groups) {
|
||||
group.isCollapsed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
btnExpandCollapseAll.updateIsAllCollapsed();
|
||||
|
||||
if (!forSetup) {
|
||||
refresh(null, -1, 0);
|
||||
@@ -520,6 +527,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
}
|
||||
else {
|
||||
otherItems = new Group("Other");
|
||||
otherItems.isCollapsed = btnExpandCollapseAll.isAllCollapsed;
|
||||
groups.add(otherItems);
|
||||
}
|
||||
}
|
||||
@@ -530,6 +538,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
|
||||
if (otherItems == null && groups.size() > groupBy.getGroups().length) {
|
||||
groups.remove(groups.size() - 1); //remove Other group if empty
|
||||
btnExpandCollapseAll.updateIsAllCollapsed();
|
||||
}
|
||||
|
||||
updateLayout(true);
|
||||
|
||||
Reference in New Issue
Block a user