diff --git a/src/main/java/forge/gui/deckeditor/controllers/CCardCatalog.java b/src/main/java/forge/gui/deckeditor/controllers/CCardCatalog.java index ad94669586a..71d0e9e351a 100644 --- a/src/main/java/forge/gui/deckeditor/controllers/CCardCatalog.java +++ b/src/main/java/forge/gui/deckeditor/controllers/CCardCatalog.java @@ -200,12 +200,18 @@ public enum CCardCatalog implements ICDoc { popup.add(range); JMenu world = new JMenu("Quest world"); for (final QuestWorld w : Singletons.getModel().getWorlds()) { + GameFormatQuest format = w.getFormat(); + if (null == format) { + // assumes that no world other than the main world will have a null format + format = Singletons.getModel().getQuest().getMainFormat(); + } + final GameFormatQuest f = format; GuiUtils.addMenuItem(world, w.getName(), null, new Runnable() { @Override public void run() { - addRestriction(buildWorldRestriction(w), activeWorlds, w); + addRestriction(buildFormatRestriction(w.getName(), f, true), activeWorlds, w); } - }, !isActive(activeWorlds, w)); + }, !isActive(activeWorlds, w) && null != f); } popup.add(world); popup.show(VCardCatalog.SINGLETON_INSTANCE.getBtnAddRestriction(), 0, @@ -366,12 +372,6 @@ public enum CCardCatalog implements ICDoc { return activeSet.contains(key); } -// private interface _RestrictionBuilder { -// Predicate getPredicate(); -// JComponent buildRestrictionWidget(); -// boolean buildMenu(JPopupMenu root, Set activeSet, T key); -// } - @SuppressWarnings("serial") private void addRestriction(Pair> restriction, final Set activeSet, final T key) { final Predicate predicate = restriction.getRight(); @@ -462,7 +462,7 @@ public enum CCardCatalog implements ICDoc { int lineLen = 0; // use HTML tooltips so we can insert line breaks - List sets = null == format ? null : format.getAllowedSetCodes(); + List sets = format.getAllowedSetCodes(); if (null == sets || sets.isEmpty()) { tooltip.append(" All"); } else { @@ -487,7 +487,7 @@ public enum CCardCatalog implements ICDoc { } } - List bannedCards = null == format ? null : format.getBannedCardNames(); + List bannedCards = format.getBannedCardNames(); if (null != bannedCards && !bannedCards.isEmpty()) { tooltip.append("

Banned:"); lastLen += lineLen; @@ -518,13 +518,4 @@ public enum CCardCatalog implements ICDoc { private Pair> buildSetRestriction(String displayName, List setCodes, boolean allowReprints) { return buildFormatRestriction(displayName, new GameFormat(null, setCodes, null), allowReprints); } - - private Pair> buildWorldRestriction(QuestWorld world) { - GameFormatQuest format = world.getFormat(); - if (null == format) { - // assumes that no world other than the main world will have a null format - format = Singletons.getModel().getQuest().getMainFormat(); - } - return buildFormatRestriction(world.getName(), format, true); - } }