mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
update format filters for Adventure Deck Editor
use FormatFilter to filter Collections, AutoSell and NoSell cards
This commit is contained in:
@@ -419,6 +419,42 @@ public class AdventureDeckEditor extends TabPageScreen<AdventureDeckEditor> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showDefault() {
|
||||||
|
if (catalogPage == null)
|
||||||
|
return;
|
||||||
|
catalogPage.showCollectionCards = true;
|
||||||
|
catalogPage.showAutoSellCards = false;
|
||||||
|
catalogPage.showNoSellCards = true;
|
||||||
|
catalogPage.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showCollection() {
|
||||||
|
if (catalogPage == null)
|
||||||
|
return;
|
||||||
|
catalogPage.showCollectionCards = true;
|
||||||
|
catalogPage.showAutoSellCards = false;
|
||||||
|
catalogPage.showNoSellCards = false;
|
||||||
|
catalogPage.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showAutoSell() {
|
||||||
|
if (catalogPage == null)
|
||||||
|
return;
|
||||||
|
catalogPage.showCollectionCards = false;
|
||||||
|
catalogPage.showAutoSellCards = true;
|
||||||
|
catalogPage.showNoSellCards = false;
|
||||||
|
catalogPage.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showNoSell() {
|
||||||
|
if (catalogPage == null)
|
||||||
|
return;
|
||||||
|
catalogPage.showCollectionCards = false;
|
||||||
|
catalogPage.showAutoSellCards = false;
|
||||||
|
catalogPage.showNoSellCards = true;
|
||||||
|
catalogPage.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
private static DeckEditorPage[] getPages(boolean isShop) {
|
private static DeckEditorPage[] getPages(boolean isShop) {
|
||||||
if (isShop) {
|
if (isShop) {
|
||||||
return new DeckEditorPage[]{
|
return new DeckEditorPage[]{
|
||||||
@@ -543,32 +579,6 @@ public class AdventureDeckEditor extends TabPageScreen<AdventureDeckEditor> {
|
|||||||
FMenuItem addBasic = new FMenuItem(Forge.getLocalizer().getMessage("lblAddBasicLands"), FSkinImage.LANDLOGO, e1 -> launchBasicLandDialog());
|
FMenuItem addBasic = new FMenuItem(Forge.getLocalizer().getMessage("lblAddBasicLands"), FSkinImage.LANDLOGO, e1 -> launchBasicLandDialog());
|
||||||
addItem(addBasic);
|
addItem(addBasic);
|
||||||
}
|
}
|
||||||
if (!isShop && catalogPage != null && !(catalogPage instanceof ContentPreviewPage)) {
|
|
||||||
if (catalogPage.showNoSellCards) {
|
|
||||||
FMenuItem hideNoSell = new FMenuItem(Forge.getLocalizer().getMessage("lblHideNoSell"), Forge.hdbuttons ? FSkinImage.HDMINUS : FSkinImage.MINUS, e1 -> catalogPage.toggleNoSellCards(false));
|
|
||||||
addItem(hideNoSell);
|
|
||||||
hideNoSell.setEnabled(catalogPage.showAutoSellCards || catalogPage.showCollectionCards);
|
|
||||||
} else {
|
|
||||||
addItem(new FMenuItem(Forge.getLocalizer().getMessage("lblShowNoSell"), Forge.hdbuttons ? FSkinImage.HDPLUS : FSkinImage.PLUS, e1 -> catalogPage.toggleNoSellCards(true)));
|
|
||||||
}
|
|
||||||
if (catalogPage.showAutoSellCards) {
|
|
||||||
FMenuItem hideAutoSell = new FMenuItem(Forge.getLocalizer().getMessage("lblHideAutoSell"), Forge.hdbuttons ? FSkinImage.HDMINUS : FSkinImage.MINUS, e1 -> catalogPage.toggleAutoSellCards(false));
|
|
||||||
addItem(hideAutoSell);
|
|
||||||
hideAutoSell.setEnabled(catalogPage.showCollectionCards || catalogPage.showNoSellCards);
|
|
||||||
} else {
|
|
||||||
addItem(new FMenuItem(Forge.getLocalizer().getMessage("lblShowAutoSell"), Forge.hdbuttons ? FSkinImage.HDPLUS : FSkinImage.PLUS, e1 -> catalogPage.toggleAutoSellCards(true)));
|
|
||||||
}
|
|
||||||
if (catalogPage.showCollectionCards) {
|
|
||||||
FMenuItem hideCollection = new FMenuItem(Forge.getLocalizer().getMessage("lblHideCollection"), Forge.hdbuttons ? FSkinImage.HDMINUS : FSkinImage.MINUS, e1 -> catalogPage.toggleCollectionCards(false));
|
|
||||||
addItem(hideCollection);
|
|
||||||
hideCollection.setEnabled(catalogPage.showAutoSellCards || catalogPage.showNoSellCards);
|
|
||||||
} else {
|
|
||||||
addItem(new FMenuItem(Forge.getLocalizer().getMessage("lblShowCollection"), Forge.hdbuttons ? FSkinImage.HDPLUS : FSkinImage.PLUS, e1 -> catalogPage.toggleCollectionCards(true)));
|
|
||||||
}
|
|
||||||
if (!catalogPage.showNoSellCards || !catalogPage.showAutoSellCards || !catalogPage.showCollectionCards) {
|
|
||||||
addItem(new FMenuItem(Forge.getLocalizer().getMessage("lblShowAll"), Forge.hdbuttons ? FSkinImage.HDPLUS : FSkinImage.PLUS, e1 -> catalogPage.showAllCards()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
((DeckEditorPage) getSelectedPage()).buildDeckMenu(this);
|
((DeckEditorPage) getSelectedPage()).buildDeckMenu(this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -589,8 +599,7 @@ public class AdventureDeckEditor extends TabPageScreen<AdventureDeckEditor> {
|
|||||||
availableEditionCodes.add(FModel.getMagicDb().getEditions().get(p.getEdition()));
|
availableEditionCodes.add(FModel.getMagicDb().getEditions().get(p.getEdition()));
|
||||||
}
|
}
|
||||||
defaultLandSet = CardEdition.Predicates.getRandomSetWithAllBasicLands(availableEditionCodes);
|
defaultLandSet = CardEdition.Predicates.getRandomSetWithAllBasicLands(availableEditionCodes);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
defaultLandSet = FModel.getMagicDb().getEditions().get("JMP");
|
defaultLandSet = FModel.getMagicDb().getEditions().get("JMP");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -751,7 +760,6 @@ public class AdventureDeckEditor extends TabPageScreen<AdventureDeckEditor> {
|
|||||||
Map<ColumnDef, ItemColumn> colOverrides = new HashMap<>();
|
Map<ColumnDef, ItemColumn> colOverrides = new HashMap<>();
|
||||||
ItemColumn.addColOverride(config, colOverrides, ColumnDef.NEW, fnNewCompare, fnNewGet);
|
ItemColumn.addColOverride(config, colOverrides, ColumnDef.NEW, fnNewCompare, fnNewGet);
|
||||||
ItemColumn.addColOverride(config, colOverrides, ColumnDef.DECKS, fnDeckCompare, fnDeckGet);
|
ItemColumn.addColOverride(config, colOverrides, ColumnDef.DECKS, fnDeckCompare, fnDeckGet);
|
||||||
|
|
||||||
cardManager.setup(config, colOverrides);
|
cardManager.setup(config, colOverrides);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -991,28 +999,6 @@ public class AdventureDeckEditor extends TabPageScreen<AdventureDeckEditor> {
|
|||||||
|
|
||||||
boolean showCollectionCards = true, showAutoSellCards = false, showNoSellCards = true;
|
boolean showCollectionCards = true, showAutoSellCards = false, showNoSellCards = true;
|
||||||
|
|
||||||
public void showAllCards() {
|
|
||||||
showCollectionCards = true;
|
|
||||||
showAutoSellCards = true;
|
|
||||||
showNoSellCards = true;
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleCollectionCards(boolean show) {
|
|
||||||
showCollectionCards = show;
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleAutoSellCards(boolean show) {
|
|
||||||
showAutoSellCards = show;
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleNoSellCards(boolean show) {
|
|
||||||
showNoSellCards = show;
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected CatalogPage(ItemManagerConfig config, String caption0, FImage icon0) {
|
protected CatalogPage(ItemManagerConfig config, String caption0, FImage icon0) {
|
||||||
super(config, caption0, icon0);
|
super(config, caption0, icon0);
|
||||||
refresh();
|
refresh();
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import com.badlogic.gdx.utils.Align;
|
|||||||
|
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.Graphics;
|
import forge.Graphics;
|
||||||
|
import forge.adventure.scene.AdventureDeckEditor;
|
||||||
|
import forge.adventure.scene.DeckEditScene;
|
||||||
import forge.assets.FSkinColor;
|
import forge.assets.FSkinColor;
|
||||||
import forge.assets.FSkinFont;
|
import forge.assets.FSkinFont;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
@@ -34,6 +36,7 @@ public abstract class FormatFilter<T extends InventoryItem> extends ItemFilter<T
|
|||||||
private String selectedFormat;
|
private String selectedFormat;
|
||||||
private boolean preventHandling = false;
|
private boolean preventHandling = false;
|
||||||
private FComboBox<Object> cbxFormats = new FComboBox<>();
|
private FComboBox<Object> cbxFormats = new FComboBox<>();
|
||||||
|
private FComboBox<Object> catalogDisplay = new FComboBox<>();
|
||||||
|
|
||||||
public FormatFilter(ItemManager<? super T> itemManager0) {
|
public FormatFilter(ItemManager<? super T> itemManager0) {
|
||||||
super(itemManager0);
|
super(itemManager0);
|
||||||
@@ -46,20 +49,31 @@ public abstract class FormatFilter<T extends InventoryItem> extends ItemFilter<T
|
|||||||
cbxFormats.addItem(Forge.getLocalizer().getMessage("lblOtherFormats"));
|
cbxFormats.addItem(Forge.getLocalizer().getMessage("lblOtherFormats"));
|
||||||
cbxFormats.addItem(Forge.getLocalizer().getMessage("lblChooseSets"));
|
cbxFormats.addItem(Forge.getLocalizer().getMessage("lblChooseSets"));
|
||||||
cbxFormats.setEnabled(!Forge.isMobileAdventureMode);
|
cbxFormats.setEnabled(!Forge.isMobileAdventureMode);
|
||||||
|
cbxFormats.setVisible(!Forge.isMobileAdventureMode);
|
||||||
|
|
||||||
|
catalogDisplay.setFont(FSkinFont.get(12));
|
||||||
|
catalogDisplay.addItem(Forge.getLocalizer().getMessage("lblShowCollection")
|
||||||
|
+ " | " + Forge.getLocalizer().getMessage("lblShowNoSell"));
|
||||||
|
catalogDisplay.addItem(Forge.getLocalizer().getMessage("lblShowCollection"));
|
||||||
|
catalogDisplay.addItem(Forge.getLocalizer().getMessage("lblShowAutoSell"));
|
||||||
|
catalogDisplay.addItem(Forge.getLocalizer().getMessage("lblShowNoSell"));
|
||||||
|
catalogDisplay.setEnabled(Forge.isMobileAdventureMode);
|
||||||
|
catalogDisplay.setVisible(Forge.isMobileAdventureMode);
|
||||||
|
|
||||||
selectedFormat = cbxFormats.getText();
|
selectedFormat = cbxFormats.getText();
|
||||||
|
|
||||||
cbxFormats.setChangedHandler(e -> {
|
cbxFormats.setChangedHandler(e -> {
|
||||||
if (preventHandling) { return; }
|
if (preventHandling) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int index = cbxFormats.getSelectedIndex();
|
int index = cbxFormats.getSelectedIndex();
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
//Do nothing when index set to -1
|
//Do nothing when index set to -1
|
||||||
}
|
} else if (index == 0) {
|
||||||
else if (index == 0) {
|
|
||||||
format = null;
|
format = null;
|
||||||
applyChange();
|
applyChange();
|
||||||
}
|
} else if (index == cbxFormats.getItemCount() - 2) {
|
||||||
else if (index == cbxFormats.getItemCount() - 2) {
|
|
||||||
preventHandling = true;
|
preventHandling = true;
|
||||||
cbxFormats.setText(selectedFormat); //restore previous selection by default
|
cbxFormats.setText(selectedFormat); //restore previous selection by default
|
||||||
preventHandling = false;
|
preventHandling = false;
|
||||||
@@ -70,18 +84,30 @@ public abstract class FormatFilter<T extends InventoryItem> extends ItemFilter<T
|
|||||||
applyChange();
|
applyChange();
|
||||||
});
|
});
|
||||||
Forge.openScreen(archivedFormatSelect);
|
Forge.openScreen(archivedFormatSelect);
|
||||||
}
|
} else if (index == cbxFormats.getItemCount() - 1) {
|
||||||
else if (index == cbxFormats.getItemCount() - 1) {
|
|
||||||
preventHandling = true;
|
preventHandling = true;
|
||||||
cbxFormats.setText(selectedFormat); //restore previous selection by default
|
cbxFormats.setText(selectedFormat); //restore previous selection by default
|
||||||
preventHandling = false;
|
preventHandling = false;
|
||||||
Forge.openScreen(new MultiSetSelect());
|
Forge.openScreen(new MultiSetSelect());
|
||||||
}
|
} else {
|
||||||
else {
|
format = (GameFormat) cbxFormats.getSelectedItem();
|
||||||
format = (GameFormat)cbxFormats.getSelectedItem();
|
|
||||||
applyChange();
|
applyChange();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
catalogDisplay.setChangedHandler(e -> {
|
||||||
|
if (preventHandling)
|
||||||
|
return;
|
||||||
|
int index = catalogDisplay.getSelectedIndex();
|
||||||
|
if (index == -1) {
|
||||||
|
//Do nothing when index set to -1
|
||||||
|
}
|
||||||
|
switch (index) {
|
||||||
|
case 0 -> ((AdventureDeckEditor) DeckEditScene.getInstance().getScreen()).showDefault();
|
||||||
|
case 1 -> ((AdventureDeckEditor) DeckEditScene.getInstance().getScreen()).showCollection();
|
||||||
|
case 2 -> ((AdventureDeckEditor) DeckEditScene.getInstance().getScreen()).showAutoSell();
|
||||||
|
case 3 -> ((AdventureDeckEditor) DeckEditScene.getInstance().getScreen()).showNoSell();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -94,12 +120,15 @@ public abstract class FormatFilter<T extends InventoryItem> extends ItemFilter<T
|
|||||||
public void reset() {
|
public void reset() {
|
||||||
preventHandling = true;
|
preventHandling = true;
|
||||||
cbxFormats.setSelectedIndex(0);
|
cbxFormats.setSelectedIndex(0);
|
||||||
|
catalogDisplay.setSelectedIndex(0);
|
||||||
preventHandling = false;
|
preventHandling = false;
|
||||||
format = null;
|
format = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FDisplayObject getMainComponent() {
|
public FDisplayObject getMainComponent() {
|
||||||
|
if (Forge.isMobileAdventureMode)
|
||||||
|
return catalogDisplay;
|
||||||
return cbxFormats;
|
return cbxFormats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,11 +139,12 @@ public abstract class FormatFilter<T extends InventoryItem> extends ItemFilter<T
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void buildWidget(Widget widget) {
|
protected void buildWidget(Widget widget) {
|
||||||
widget.add(cbxFormats);
|
widget.add(Forge.isMobileAdventureMode ? catalogDisplay : cbxFormats);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doWidgetLayout(float width, float height) {
|
protected void doWidgetLayout(float width, float height) {
|
||||||
|
catalogDisplay.setSize(width, height);
|
||||||
cbxFormats.setSize(width, height);
|
cbxFormats.setSize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +169,6 @@ public abstract class FormatFilter<T extends InventoryItem> extends ItemFilter<T
|
|||||||
lstSets.addGroup("Draft Innovation Sets");
|
lstSets.addGroup("Draft Innovation Sets");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lstSets.addGroup("Commander Sets");
|
lstSets.addGroup("Commander Sets");
|
||||||
lstSets.addGroup("Multiplayer Sets");
|
lstSets.addGroup("Multiplayer Sets");
|
||||||
lstSets.addGroup("Other Supplemental Sets");
|
lstSets.addGroup("Other Supplemental Sets");
|
||||||
@@ -163,7 +192,7 @@ public abstract class FormatFilter<T extends InventoryItem> extends ItemFilter<T
|
|||||||
lstSets.addItem(set, 3);
|
lstSets.addItem(set, 3);
|
||||||
break;
|
break;
|
||||||
case BOXED_SET:
|
case BOXED_SET:
|
||||||
lstSets.addItem(set,4);
|
lstSets.addItem(set, 4);
|
||||||
break;
|
break;
|
||||||
case COLLECTOR_EDITION:
|
case COLLECTOR_EDITION:
|
||||||
lstSets.addItem(set, 5);
|
lstSets.addItem(set, 5);
|
||||||
@@ -233,12 +262,10 @@ public abstract class FormatFilter<T extends InventoryItem> extends ItemFilter<T
|
|||||||
if (selectedSets.contains(value)) {
|
if (selectedSets.contains(value)) {
|
||||||
if (count == 2) {
|
if (count == 2) {
|
||||||
Forge.back(); //support double tap to confirm selection without unselecting double tapped item
|
Forge.back(); //support double tap to confirm selection without unselecting double tapped item
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
selectedSets.remove(value);
|
selectedSets.remove(value);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
selectedSets.add(value);
|
selectedSets.add(value);
|
||||||
if (count == 2) {
|
if (count == 2) {
|
||||||
Forge.back(); //support double tap to confirm selection after selecting double tapped item
|
Forge.back(); //support double tap to confirm selection after selecting double tapped item
|
||||||
|
|||||||
Reference in New Issue
Block a user