diff --git a/src/main/java/forge/gui/GuiChoose.java b/src/main/java/forge/gui/GuiChoose.java index 40235878255..1c48a7cfa47 100644 --- a/src/main/java/forge/gui/GuiChoose.java +++ b/src/main/java/forge/gui/GuiChoose.java @@ -171,7 +171,7 @@ public class GuiChoose { * @return a {@link java.util.List} object. */ private static List getChoices(final String message, final int min, final int max, final T[] choices) { - final ListChooser c = new ListChooser(message, min, max, choices); + final ListChooser c = new ListChooser(message, null, min, max, choices); return getChoices(c); } diff --git a/src/main/java/forge/gui/GuiDisplayUtil.java b/src/main/java/forge/gui/GuiDisplayUtil.java index e8498d749d1..a194f7851b0 100644 --- a/src/main/java/forge/gui/GuiDisplayUtil.java +++ b/src/main/java/forge/gui/GuiDisplayUtil.java @@ -749,11 +749,12 @@ public final class GuiDisplayUtil { Collections.sort(cards); // use standard forge's list selection dialog - final ListChooser c = new ListChooser("Name the card", 0, 1, cards); - if (c.show()) { - Card forgeCard = c.getSelectedValue().toForgeCard(p); - Singletons.getModel().getGame().getAction().moveToHand(forgeCard); - } + final CardPrinted c = GuiChoose.oneOrNone("Name the card", cards); + if (c == null) return; + + Card forgeCard = c.toForgeCard(p); + Singletons.getModel().getGame().getAction().moveToHand(forgeCard); + } public static void devModeCardToBattlefield() { @@ -765,22 +766,23 @@ public final class GuiDisplayUtil { Collections.sort(cards); // use standard forge's list selection dialog - final ListChooser c = new ListChooser("Name the card", 0, 1, cards); - if (c.show()) { - Card forgeCard = c.getSelectedValue().toForgeCard(p); - - final List choices = forgeCard.getBasicSpells(); - if (choices.isEmpty()) return; // when would it happen? + final CardPrinted c = GuiChoose.oneOrNone("Name the card", cards); + if (c == null) return; + + Card forgeCard = c.toForgeCard(p); + + final List choices = forgeCard.getBasicSpells(); + if (choices.isEmpty()) return; // when would it happen? - final SpellAbility sa = choices.size() == 1 ? choices.get(0) : GuiChoose.oneOrNone("Choose", choices); - if (sa == null) return; // happends if cancelled + final SpellAbility sa = choices.size() == 1 ? choices.get(0) : GuiChoose.oneOrNone("Choose", choices); + if (sa == null) return; // happens if cancelled - sa.setActivatingPlayer(p); + sa.setActivatingPlayer(p); + + final GameState game = Singletons.getModel().getGame(); + game.getAction().moveToHand(forgeCard); // this is really needed + game.getAction().playSpellAbilityForFree(sa); - final GameState game = Singletons.getModel().getGame(); - game.getAction().moveToHand(forgeCard); // this is really needed - game.getAction().playSpellAbilityForFree(sa); - } } diff --git a/src/main/java/forge/gui/ListChooser.java b/src/main/java/forge/gui/ListChooser.java index f10d96a792a..63c909d34a3 100644 --- a/src/main/java/forge/gui/ListChooser.java +++ b/src/main/java/forge/gui/ListChooser.java @@ -83,87 +83,6 @@ public class ListChooser { private JOptionPane optionPane; private Action ok, cancel; - /** - *

- * Constructor for ListChooser. - *

- * - * @param title - * a {@link java.lang.String} object. - * @param list - * a T object. - */ - public ListChooser(final String title, final T[] list) { - this(title, 1, list); - } - - /** - *

- * Constructor for ListChooser. - *

- * - * @param title - * a {@link java.lang.String} object. - * @param numChoices - * a int. - * @param list - * a T object. - */ - public ListChooser(final String title, final int numChoices, final T[] list) { - this(title, numChoices, numChoices, list); - } - - /** - *

- * Constructor for ListChooser. - *

- * - * @param title - * a {@link java.lang.String} object. - * @param minChoices - * a int. - * @param maxChoices - * a int. - * @param list - * a T object. - */ - public ListChooser(final String title, final int minChoices, final int maxChoices, final T[] list) { - this(title, null, minChoices, maxChoices, list); - } - - /** - *

- * Constructor for ListChooser. - *

- * - * @param title - * a {@link java.lang.String} object. - * @param message - * a {@link java.lang.String} object. - * @param list - * a T object. - */ - public ListChooser(final String title, final String message, final T[] list) { - this(title, message, 1, list); - } - - /** - *

- * Constructor for ListChooser. - *

- * - * @param title - * a {@link java.lang.String} object. - * @param message - * a {@link java.lang.String} object. - * @param numChoices - * a int. - * @param list - * a T object. - */ - public ListChooser(final String title, final String message, final int numChoices, final T[] list) { - this(title, message, numChoices, numChoices, list); - } /** *

@@ -186,36 +105,6 @@ public class ListChooser { this(title, message, minChoices, maxChoices, Arrays.asList(list)); } - /** - *

- * Constructor for ListChooser. - *

- * - * @param title - * a {@link java.lang.String} object. - * @param list - * a {@link java.util.List} object. - */ - public ListChooser(final String title, final List list) { - this(title, 1, list); - } - - /** - *

- * Constructor for ListChooser. - *

- * - * @param title - * a {@link java.lang.String} object. - * @param numChoices - * a int. - * @param list - * a {@link java.util.List} object. - */ - public ListChooser(final String title, final int numChoices, final Collection list) { - this(title, numChoices, numChoices, list); - } - /** *

* Constructor for ListChooser. @@ -234,40 +123,6 @@ public class ListChooser { this(title, null, minChoices, maxChoices, list); } - /** - *

- * Constructor for ListChooser. - *

- * - * @param title - * a {@link java.lang.String} object. - * @param message - * a {@link java.lang.String} object. - * @param list - * a {@link java.util.List} object. - */ - public ListChooser(final String title, final String message, final Collection list) { - this(title, message, 1, list); - } - - /** - *

- * Constructor for ListChooser. - *

- * - * @param title - * a {@link java.lang.String} object. - * @param message - * a {@link java.lang.String} object. - * @param numChoices - * a int. - * @param list - * a {@link java.util.List} object. - */ - public ListChooser(final String title, final String message, final int numChoices, final Collection list) { - this(title, message, numChoices, numChoices, list); - } - /** *

* Constructor for ListChooser. diff --git a/src/main/java/forge/gui/match/QuestWinLose.java b/src/main/java/forge/gui/match/QuestWinLose.java index d6565e7607e..37246b0c28d 100644 --- a/src/main/java/forge/gui/match/QuestWinLose.java +++ b/src/main/java/forge/gui/match/QuestWinLose.java @@ -544,7 +544,7 @@ public class QuestWinLose extends ControlWinLose { i++; } - final ListChooser ch = new ListChooser("Choose bonus booster format", 1, formats); + final ListChooser ch = new ListChooser("Choose bonus booster format", 1, 1, formats); ch.show(index); final GameFormat selected = ch.getSelectedValue();