mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Refactoring method in FModel to return all block formats
This method is currently used in CardManager and DeckManager for Block Filter when Historic format are supported in forge. However, now the same method will also be used in Deck Import so this refactoring was very much necessary! Signed-off-by: leriomaggio <valeriomaggio@gmail.com>
This commit is contained in:
@@ -233,15 +233,7 @@ public class CardManager extends ItemManager<PaperCard> {
|
|||||||
|
|
||||||
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.LOAD_HISTORIC_FORMATS)) {
|
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.LOAD_HISTORIC_FORMATS)) {
|
||||||
JMenu blocks = GuiUtils.createMenu(localizer.getMessage("lblBlock"));
|
JMenu blocks = GuiUtils.createMenu(localizer.getMessage("lblBlock"));
|
||||||
List<GameFormat> blockFormats = new ArrayList<>();
|
final List<GameFormat> blockFormats = FModel.getBlockFormats();
|
||||||
for (GameFormat format : FModel.getFormats().getHistoricList()){
|
|
||||||
if (format.getFormatSubType() != GameFormat.FormatSubType.BLOCK)
|
|
||||||
continue;
|
|
||||||
if (!format.getName().endsWith("Block"))
|
|
||||||
continue;
|
|
||||||
blockFormats.add(format);
|
|
||||||
}
|
|
||||||
Collections.sort(blockFormats); // GameFormat will be sorted by Index!
|
|
||||||
for (final GameFormat f : blockFormats) {
|
for (final GameFormat f : blockFormats) {
|
||||||
GuiUtils.addMenuItem(blocks, f.getName(), null, new Runnable() {
|
GuiUtils.addMenuItem(blocks, f.getName(), null, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -281,15 +281,7 @@ public final class DeckManager extends ItemManager<DeckProxy> implements IHasGam
|
|||||||
|
|
||||||
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.LOAD_HISTORIC_FORMATS)) {
|
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.LOAD_HISTORIC_FORMATS)) {
|
||||||
JMenu blocks = GuiUtils.createMenu(localizer.getMessage("lblBlock"));
|
JMenu blocks = GuiUtils.createMenu(localizer.getMessage("lblBlock"));
|
||||||
List<GameFormat> blockFormats = new ArrayList<>();
|
final List<GameFormat> blockFormats = FModel.getBlockFormats();
|
||||||
for (GameFormat format : FModel.getFormats().getHistoricList()){
|
|
||||||
if (format.getFormatSubType() != GameFormat.FormatSubType.BLOCK)
|
|
||||||
continue;
|
|
||||||
if (!format.getName().endsWith("Block"))
|
|
||||||
continue;
|
|
||||||
blockFormats.add(format);
|
|
||||||
}
|
|
||||||
Collections.sort(blockFormats); // GameFormat will be sorted by Index!
|
|
||||||
for (final GameFormat f : blockFormats) {
|
for (final GameFormat f : blockFormats) {
|
||||||
GuiUtils.addMenuItem(blocks, f.getName(), null, new Runnable() {
|
GuiUtils.addMenuItem(blocks, f.getName(), null, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -64,9 +64,7 @@ import forge.util.storage.IStorage;
|
|||||||
import forge.util.storage.StorageBase;
|
import forge.util.storage.StorageBase;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default Model implementation for Forge.
|
* The default Model implementation for Forge.
|
||||||
@@ -465,6 +463,19 @@ public final class FModel {
|
|||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<GameFormat> getBlockFormats(){
|
||||||
|
List<GameFormat> blockFormats = new ArrayList<>();
|
||||||
|
for (GameFormat format : FModel.getFormats().getHistoricList()){
|
||||||
|
if (format.getFormatSubType() != GameFormat.FormatSubType.BLOCK)
|
||||||
|
continue;
|
||||||
|
if (!format.getName().endsWith("Block"))
|
||||||
|
continue;
|
||||||
|
blockFormats.add(format);
|
||||||
|
}
|
||||||
|
Collections.sort(blockFormats); // GameFormat will be sorted by Index!
|
||||||
|
return blockFormats;
|
||||||
|
}
|
||||||
|
|
||||||
public static QuestPreferences getQuestPreferences() {
|
public static QuestPreferences getQuestPreferences() {
|
||||||
return questPreferences;
|
return questPreferences;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user