mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Attempt to add other formats to format filter submenu on android
This commit is contained in:
@@ -45,6 +45,7 @@ public abstract class FormatFilter<T extends InventoryItem> extends ItemFilter<T
|
||||
for (GameFormat format : FModel.getFormats().getFilterList()) {
|
||||
cbxFormats.addItem(format);
|
||||
}
|
||||
cbxFormats.addItem("Other Formats...");
|
||||
cbxFormats.addItem("Choose Sets...");
|
||||
selectedFormat = cbxFormats.getText();
|
||||
|
||||
@@ -61,6 +62,12 @@ public abstract class FormatFilter<T extends InventoryItem> extends ItemFilter<T
|
||||
format = null;
|
||||
applyChange();
|
||||
}
|
||||
else if (index == cbxFormats.getItemCount() - 2) {
|
||||
preventHandling = true;
|
||||
cbxFormats.setText(selectedFormat); //restore previous selection by default
|
||||
preventHandling = false;
|
||||
Forge.openScreen(new HistoricFormatSelect());
|
||||
}
|
||||
else if (index == cbxFormats.getItemCount() - 1) {
|
||||
preventHandling = true;
|
||||
cbxFormats.setText(selectedFormat); //restore previous selection by default
|
||||
@@ -109,6 +116,78 @@ public abstract class FormatFilter<T extends InventoryItem> extends ItemFilter<T
|
||||
cbxFormats.setSize(width, height);
|
||||
}
|
||||
|
||||
private class HistoricFormatSelect extends FScreen {
|
||||
private GameFormat selectedFormat;
|
||||
private final FGroupList<GameFormat> lstFormats = add(new FGroupList<GameFormat>());
|
||||
private HistoricFormatSelect() {
|
||||
super("Choose Format");
|
||||
for (GameFormat.FormatType group:GameFormat.FormatType.values()){
|
||||
lstFormats.addGroup(group.name());
|
||||
}
|
||||
for (GameFormat format: FModel.getFormats().getOrderedList()){
|
||||
switch(format.getFormatType()){
|
||||
case Sanctioned:
|
||||
lstFormats.addItem(format, 0);
|
||||
break;
|
||||
case Casual:
|
||||
lstFormats.addItem(format, 1);
|
||||
break;
|
||||
case Historic:
|
||||
lstFormats.addItem(format, 2);
|
||||
break;
|
||||
case Custom:
|
||||
lstFormats.addItem(format, 3);
|
||||
}
|
||||
}
|
||||
lstFormats.setListItemRenderer(new FormatRenderer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(Callback<Boolean> canCloseCallback) {
|
||||
if (selectedFormat != null) {
|
||||
format = selectedFormat;
|
||||
cbxFormats.setText(selectedFormat.getName());
|
||||
applyChange();
|
||||
}
|
||||
super.onClose(canCloseCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doLayout(float startY, float width, float height) {
|
||||
lstFormats.setBounds(0, startY, width, height - startY);
|
||||
}
|
||||
|
||||
private class FormatRenderer extends FList.ListItemRenderer<GameFormat>{
|
||||
@Override
|
||||
public float getItemHeight() {
|
||||
return Utils.AVG_FINGER_HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tap(Integer index, GameFormat value, float x, float y, int count) {
|
||||
selectedFormat=value;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawValue(Graphics g, Integer index, GameFormat value, FSkinFont font, FSkinColor foreColor, FSkinColor backColor, boolean pressed, float x, float y, float w, float h) {
|
||||
float offset = SettingsScreen.getInsets(w) - FList.PADDING; //increase padding for settings items
|
||||
x += offset;
|
||||
y += offset;
|
||||
w -= 2 * offset;
|
||||
h -= 2 * offset;
|
||||
|
||||
float textHeight = h;
|
||||
h *= 0.66f;
|
||||
|
||||
g.drawText(value.toString(), font, foreColor, x, y, w - h - FList.PADDING, textHeight, false, HAlignment.LEFT, true);
|
||||
|
||||
x += w - h;
|
||||
y += (textHeight - h) / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MultiSetSelect extends FScreen {
|
||||
private final Set<CardEdition> selectedSets = new HashSet<CardEdition>();
|
||||
private final FGroupList<CardEdition> lstSets = add(new FGroupList<CardEdition>());
|
||||
|
||||
Reference in New Issue
Block a user