diff --git a/.gitattributes b/.gitattributes index 3da9ba949be..e8ab9e58578 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12654,6 +12654,7 @@ src/main/java/forge/gui/CardPicturePanel.java svneol=native#text/plain src/main/java/forge/gui/DualListBox.java -text src/main/java/forge/gui/ForgeAction.java svneol=native#text/plain src/main/java/forge/gui/GuiAssignDamageFrame.java svneol=native#text/plain +src/main/java/forge/gui/GuiChoose.java -text src/main/java/forge/gui/GuiDisplayUtil.java svneol=native#text/plain src/main/java/forge/gui/GuiImportPicture.java svneol=native#text/plain src/main/java/forge/gui/GuiInput.java svneol=native#text/plain diff --git a/src/main/java/forge/GameAction.java b/src/main/java/forge/GameAction.java index 08c9c41ddd6..fdae5eef12f 100644 --- a/src/main/java/forge/GameAction.java +++ b/src/main/java/forge/GameAction.java @@ -58,7 +58,7 @@ import forge.game.player.Player; import forge.game.zone.PlayerZone; import forge.game.zone.PlayerZoneComesIntoPlay; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.match.ViewWinLose; @@ -1334,7 +1334,7 @@ public class GameAction { crd = list.get(0); } else { if (c.getController().isHuman()) { - crd = GuiUtils.chooseOneOrNone("Select totem armor to destroy", list); + crd = GuiChoose.oneOrNone("Select totem armor to destroy", list); } else { crd = list.get(0); } @@ -1517,7 +1517,7 @@ public class GameAction { crd = list.get(0); } else { if (c.getController().isHuman()) { - crd = GuiUtils.chooseOneOrNone("Select totem armor to destroy", list); + crd = GuiChoose.oneOrNone("Select totem armor to destroy", list); } else { crd = list.get(0); } @@ -1581,7 +1581,7 @@ public class GameAction { } else if (choices.size() == 1) { choice = choices.get(0); } else { - choice = (String) GuiUtils.chooseOneOrNone("Choose", choices); + choice = (String) GuiChoose.oneOrNone("Choose", choices); } if (choice == null) { @@ -1619,7 +1619,7 @@ public class GameAction { } else if (choices.size() == 1) { sa = choices.get(0); } else { - sa = (SpellAbility) GuiUtils.chooseOneOrNone("Choose", choices); + sa = (SpellAbility) GuiChoose.oneOrNone("Choose", choices); } if (sa == null) { @@ -1708,12 +1708,12 @@ public class GameAction { cntChoice[i] = Integer.valueOf(i); } - final Integer chosenAmount = (Integer) GuiUtils.chooseOne("Exile how many cards?", cntChoice); + final Integer chosenAmount = (Integer) GuiChoose.one("Exile how many cards?", cntChoice); System.out.println("Delve for " + chosenAmount); final CardList choices = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard); final CardList chosen = new CardList(); for (int i = 0; i < chosenAmount; i++) { - final Card nowChosen = GuiUtils.chooseOneOrNone("Exile which card?", choices); + final Card nowChosen = GuiChoose.oneOrNone("Exile which card?", choices); if (nowChosen == null) { // User canceled,abort delving. @@ -1790,7 +1790,7 @@ public class GameAction { ManaCost newCost = new ManaCost(originalCost.toString()); Object tapForConvoke = null; if (sa.getActivatingPlayer().isHuman()) { - tapForConvoke = GuiUtils.chooseOneOrNone("Tap for Convoke? " + newCost.toString(), + tapForConvoke = GuiChoose.oneOrNone("Tap for Convoke? " + newCost.toString(), choices); } else { // TODO: AI to choose a creature to tap would go here @@ -1805,7 +1805,7 @@ public class GameAction { String chosenColor = usableColors.get(0); if (usableColors.size() > 1) { if (sa.getActivatingPlayer().isHuman()) { - chosenColor = (String) GuiUtils.chooseOne("Convoke for which color?", + chosenColor = (String) GuiChoose.one("Convoke for which color?", usableColors); } else { // TODO: AI for choosing which color to @@ -1833,7 +1833,7 @@ public class GameAction { } if (sa.getActivatingPlayer().isHuman()) { - tapForConvoke = GuiUtils.chooseOneOrNone("Tap for Convoke? " + newCost.toString(), choices); + tapForConvoke = GuiChoose.oneOrNone("Tap for Convoke? " + newCost.toString(), choices); } else { // TODO: AI to choose a creature to tap would go // here @@ -1929,7 +1929,7 @@ public class GameAction { } else if (choices.size() == 1) { choice = choices.get(0); } else { - choice = (String) GuiUtils.chooseOneOrNone("Choose", choices); + choice = (String) GuiChoose.oneOrNone("Choose", choices); } final SpellAbility ability = map.get(choice); diff --git a/src/main/java/forge/GameActionUtil.java b/src/main/java/forge/GameActionUtil.java index 55b075ff6c4..71912e02654 100644 --- a/src/main/java/forge/GameActionUtil.java +++ b/src/main/java/forge/GameActionUtil.java @@ -52,7 +52,7 @@ import forge.game.GameLossReason; import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.match.CMatchUI; import forge.util.MyRandom; @@ -155,7 +155,7 @@ public final class GameActionUtil { } } // while - GuiUtils.chooseOneOrNone("Revealed cards:", revealed); + GuiChoose.oneOrNone("Revealed cards:", revealed); if (cascadedCard != null) { @@ -287,7 +287,7 @@ public final class GameActionUtil { rippledCards[i] = crd; } } // for - GuiUtils.chooseOneOrNone("Revealed cards:", revealed); + GuiChoose.oneOrNone("Revealed cards:", revealed); for (int i = 0; i < rippleMax; i++) { if (rippledCards[i] != null) { @@ -628,7 +628,7 @@ public final class GameActionUtil { final boolean flip = MyRandom.getRandom().nextBoolean(); if (caller.isHuman()) { - choice = GuiUtils.chooseOne(source.getName() + " - Call coin flip", choices); + choice = GuiChoose.one(source.getName() + " - Call coin flip", choices); } else { choice = choices[MyRandom.getRandom().nextInt(2)]; } diff --git a/src/main/java/forge/card/CardRulesPredicates.java b/src/main/java/forge/card/CardRulesPredicates.java index f71b95c8a2c..7d9163dda16 100644 --- a/src/main/java/forge/card/CardRulesPredicates.java +++ b/src/main/java/forge/card/CardRulesPredicates.java @@ -505,8 +505,7 @@ public final class CardRulesPredicates { public static final Predicate IS_NON_LAND = CardRulesPredicates.coreType(false, CardCoreType.Land); /** The Constant isNonCreatureSpell. */ - public static final Predicate IS_CREATURE_OR_LAND = Predicates.or(Presets.IS_CREATURE,Presets.IS_LAND); - public static final Predicate IS_NON_CREATURE_SPELL = Predicates.not(IS_CREATURE_OR_LAND); + public static final Predicate IS_NON_CREATURE_SPELL = Predicates.not(Predicates.or(Presets.IS_CREATURE,Presets.IS_LAND)); @SuppressWarnings("unchecked") public static final Predicate IS_NONCREATURE_SPELL_FOR_GENERATOR = diff --git a/src/main/java/forge/card/UnOpenedMeta.java b/src/main/java/forge/card/UnOpenedMeta.java index ed9745d8f81..00b5949613d 100644 --- a/src/main/java/forge/card/UnOpenedMeta.java +++ b/src/main/java/forge/card/UnOpenedMeta.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Random; import forge.Singletons; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.item.CardPrinted; import forge.util.MyRandom; @@ -127,7 +127,7 @@ public class UnOpenedMeta extends UnOpenedProduct { for (MetaSet meta : metaSets) { choices.add(meta.getCode()); } - final Object o = GuiUtils.chooseOne("Choose booster:", choices); + final Object o = GuiChoose.one("Choose booster:", choices); for (int i = 0; i < metaSets.size(); i++) { if (o.toString().equals(metaSets.get(i).getCode())) { diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java index 586df1abc04..37d4011c9df 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java @@ -51,7 +51,7 @@ import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.util.MyRandom; @@ -1408,7 +1408,7 @@ public class AbilityFactoryAttach { } } - final Player p = GuiUtils.chooseOne(source + " - Select a player to attach to.", players); + final Player p = GuiChoose.one(source + " - Select a player to attach to.", players); if (p != null) { AbilityFactoryAttach.handleAura(source, p, false); //source.enchantEntity((Player) o); @@ -1418,7 +1418,7 @@ public class AbilityFactoryAttach { CardList list = AllZoneUtil.getCardsIn(tgt.getZone()); list = list.getValidCards(tgt.getValidTgts(), aura.getActivatingPlayer(), source); - final Object o = GuiUtils.chooseOne(source + " - Select a card to attach to.", list); + final Object o = GuiChoose.one(source + " - Select a card to attach to.", list); if (o instanceof Card) { AbilityFactoryAttach.handleAura(source, (Card) o, gainControl); //source.enchantEntity((Card) o); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryBond.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryBond.java index 2c2b32ed46a..69f94bde258 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryBond.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryBond.java @@ -30,7 +30,7 @@ import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; import forge.game.player.ComputerUtil; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; /** *

@@ -333,7 +333,7 @@ public final class AbilityFactoryBond { if (cards.size() == 1) { partner = cards.get(0); } else if (sa.getActivatingPlayer().isHuman()) { - Object o = GuiUtils.chooseOne("Select a card to pair with", cards); + Object o = GuiChoose.one("Select a card to pair with", cards); if (o != null) { partner = (Card) o; diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java index a7f2ebadf71..b4a251ebe59 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java @@ -58,7 +58,7 @@ import forge.game.player.ComputerUtilBlock; import forge.game.player.Player; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.util.MyRandom; @@ -965,13 +965,13 @@ public final class AbilityFactoryChangeZone { if (!defined) { if (origin.contains(ZoneType.Library) && !defined && !params.containsKey("NoLooking")) { // Look at whole library before moving onto choosing a card - GuiUtils.chooseOneOrNone(sa.getSourceCard().getName() + " - Looking at Library", + GuiChoose.oneOrNone(sa.getSourceCard().getName() + " - Looking at Library", player.getCardsIn(ZoneType.Library)); } // Look at opponents hand before moving onto choosing a card if (origin.contains(ZoneType.Hand) && player.isComputer()) { - GuiUtils.chooseOneOrNone(sa.getSourceCard().getName() + " - Looking at Opponent's Hand", player + GuiChoose.oneOrNone(sa.getSourceCard().getName() + " - Looking at Opponent's Hand", player .getCardsIn(ZoneType.Hand)); } fetchList = AbilityFactory.filterListByType(fetchList, params.get("ChangeType"), sa); @@ -995,11 +995,11 @@ public final class AbilityFactoryChangeZone { if (params.containsKey("AtRandom")) { o = CardUtil.getRandom(fetchList); } else if (params.containsKey("Mandatory")) { - o = GuiUtils.chooseOne(selectPrompt, fetchList); + o = GuiChoose.one(selectPrompt, fetchList); } else if (params.containsKey("Defined")) { o = fetchList.get(0); } else { - o = GuiUtils.chooseOneOrNone(selectPrompt, fetchList); + o = GuiChoose.oneOrNone(selectPrompt, fetchList); } if (o != null) { @@ -1083,7 +1083,7 @@ public final class AbilityFactoryChangeZone { } } if (params.containsKey("Reveal") && !reveal.isEmpty()) { - GuiUtils.chooseOne(card + " - Revealed card: ", reveal.toArray()); + GuiChoose.one(card + " - Revealed card: ", reveal.toArray()); } if ((origin.contains(ZoneType.Library) && !destination.equals(ZoneType.Library) && !defined) @@ -1337,9 +1337,9 @@ public final class AbilityFactoryChangeZone { if (!ZoneType.Battlefield.equals(destination) && !"Card".equals(type) && !defined) { final String picked = sa.getSourceCard().getName() + " - Computer picked:"; if (fetched.size() > 0) { - GuiUtils.chooseOne(picked, fetched); + GuiChoose.one(picked, fetched); } else { - GuiUtils.chooseOne(picked, new String[] { "" }); + GuiChoose.one(picked, new String[] { "" }); } } } // end changeHiddenOriginResolveAI diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCharm.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCharm.java index 29b26a4a406..dc944553881 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCharm.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCharm.java @@ -30,7 +30,7 @@ import forge.card.spellability.SpellAbility; import forge.card.spellability.Target; import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.util.MyRandom; // Charm specific params: @@ -246,9 +246,9 @@ public final class AbilityFactoryCharm { for (int i = 0; i < num; i++) { Object o; if (i < min) { - o = GuiUtils.chooseOne("Choose a mode", choices); + o = GuiChoose.one("Choose a mode", choices); } else { - o = GuiUtils.chooseOneOrNone("Choose a mode", choices); + o = GuiChoose.oneOrNone("Choose a mode", choices); } if (null == o) { return sa; diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java index f251c526872..a6cb5412748 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java @@ -48,7 +48,7 @@ import forge.card.cost.Cost; import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.ListChooser; import forge.item.CardDb; import forge.item.CardPrinted; @@ -338,7 +338,7 @@ public final class AbilityFactoryChoose { boolean valid = false; while (!valid) { if (sa.getActivatingPlayer().isHuman()) { - final Object o = GuiUtils.chooseOne("Choose a card type", Constant.CardTypes.CARD_TYPES); + final Object o = GuiChoose.one("Choose a card type", Constant.CardTypes.CARD_TYPES); if (null == o) { return; } @@ -364,7 +364,7 @@ public final class AbilityFactoryChoose { for (final String s : invalidTypes) { validChoices.remove(s); } - final Object o = GuiUtils.chooseOne("Choose a creature type", validChoices); + final Object o = GuiChoose.one("Choose a creature type", validChoices); if (null == o) { return; } @@ -405,7 +405,7 @@ public final class AbilityFactoryChoose { if (!CardUtil.isACreatureType(chosen) || invalidTypes.contains(chosen)) { chosen = "Sliver"; } - GuiUtils.chooseOne("Computer picked: ", new String[]{chosen}); + GuiChoose.one("Computer picked: ", new String[]{chosen}); chosenType = chosen; } if (CardUtil.isACreatureType(chosenType) && !invalidTypes.contains(chosenType)) { @@ -417,7 +417,7 @@ public final class AbilityFactoryChoose { boolean valid = false; while (!valid) { if (sa.getActivatingPlayer().isHuman()) { - final String choice = GuiUtils.chooseOne("Choose a basic land type", CardUtil.getBasicTypes()); + final String choice = GuiChoose.one("Choose a basic land type", CardUtil.getBasicTypes()); if (null == choice) { return; } @@ -434,8 +434,8 @@ public final class AbilityFactoryChoose { boolean valid = false; while (!valid) { if (sa.getActivatingPlayer().isHuman()) { - final String choice = GuiUtils - .chooseOne("Choose a land type", CardUtil.getLandTypes()); + final String choice = GuiChoose + .one("Choose a land type", CardUtil.getLandTypes()); if (null == choice) { return; } @@ -708,11 +708,11 @@ public final class AbilityFactoryChoose { if ((tgt == null) || p.canBeTargetedBy(sa)) { if (sa.getActivatingPlayer().isHuman()) { if (params.containsKey("OrColors")) { - final List o = GuiUtils.chooseOneOrMany("Choose a color or colors", + final List o = GuiChoose.oneOrMany("Choose a color or colors", Constant.Color.ONLY_COLORS); card.setChosenColor(new ArrayList(o)); } else { - final Object o = GuiUtils.chooseOne("Choose a color", Constant.Color.ONLY_COLORS); + final Object o = GuiChoose.one("Choose a color", Constant.Color.ONLY_COLORS); if (null == o) { return; } @@ -759,7 +759,7 @@ public final class AbilityFactoryChoose { if (chosen.equals("")) { chosen = Constant.Color.GREEN; } - GuiUtils.chooseOne("Computer picked: ", new String[]{chosen}); + GuiChoose.one("Computer picked: ", new String[]{chosen}); final ArrayList colorTemp = new ArrayList(); colorTemp.add(chosen); card.setChosenColor(colorTemp); @@ -1043,13 +1043,13 @@ public final class AbilityFactoryChoose { final String message = "Randomly chosen number: " + chosen; JOptionPane.showMessageDialog(null, message, "" + card, JOptionPane.PLAIN_MESSAGE); } else if (params.containsKey("ListTitle")) { - final Object o = GuiUtils.chooseOne(params.get("ListTitle"), choices); + final Object o = GuiChoose.one(params.get("ListTitle"), choices); if (null == o) { return; } chosen = Integer.parseInt((String) o); } else { - final Object o = GuiUtils.chooseOne("Choose a number", choices); + final Object o = GuiChoose.one("Choose a number", choices); if (null == o) { return; } @@ -1312,7 +1312,7 @@ public final class AbilityFactoryChoose { // Was if (sa.getActivatingPlayer().isHuman()) but defined player was being // overwritten by activatingPlayer (or controller if no activator was set). // Revert if it causes issues and remove Goblin Festival from card database. - final Object o = GuiUtils.chooseOne(choiceDesc, choices); + final Object o = GuiChoose.one(choiceDesc, choices); if (null == o) { return; } @@ -1653,7 +1653,7 @@ public final class AbilityFactoryChoose { if (chosen.equals("")) { chosen = "Morphling"; } - GuiUtils.chooseOne("Computer picked: ", new String[]{chosen}); + GuiChoose.one("Computer picked: ", new String[]{chosen}); host.setNamedCard(chosen); ok = true; } @@ -1953,7 +1953,7 @@ public final class AbilityFactoryChoose { final CardList cl = land.getType(type); if (cl.size() > 0) { final String prompt = "Choose a" + (type.equals("Island") ? "n " : " ") + type; - final Object o = GuiUtils.chooseOne(prompt, cl); + final Object o = GuiChoose.one(prompt, cl); if (null != o) { final Card c = (Card) o; chosen.add(c); @@ -1969,7 +1969,7 @@ public final class AbilityFactoryChoose { for (int i = 0; i < validAmount; i++) { if (p.isHuman()) { final String choiceTitle = params.containsKey("ChoiceTitle") ? params.get("ChoiceTitle") : "Choose a card "; - final Card o = GuiUtils.chooseOneOrNone(choiceTitle, choices); + final Card o = GuiChoose.oneOrNone(choiceTitle, choices); if (o != null) { chosen.add((Card) o); choices.remove((Card) o); @@ -2231,7 +2231,7 @@ public final class AbilityFactoryChoose { SpellAbility chosenSA = null; AbilityFactory afChoice = new AbilityFactory(); if (p.isHuman()) { - String choice = (String) GuiUtils.chooseOne("Choose one", choices.values()); + String choice = (String) GuiChoose.one("Choose one", choices.values()); chosenSA = afChoice.getAbility(host.getSVar(choices.inverse().get(choice)), host); } else { //Computer AI chosenSA = afChoice.getAbility(host.getSVar(params.get("Choices").split(",")[0]), host); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java index e16a5b206ca..de5a7203ca5 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java @@ -37,7 +37,7 @@ import forge.card.cost.Cost; import forge.card.trigger.TriggerType; import forge.game.player.Player; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; /** *

@@ -766,7 +766,7 @@ public final class AbilityFactoryClash { // first, separate the cards into piles if (separator.isHuman()) { - final List firstPile = GuiUtils.getOrderChoices("Place into two piles", "Pile 1", -1, pool.toArray(), null); + final List firstPile = GuiChoose.getOrderChoices("Place into two piles", "Pile 1", -1, pool.toArray(), null); for (final Object o : firstPile) { pile1.add((Card)o); } @@ -886,7 +886,7 @@ public final class AbilityFactoryClash { // make sure Pile 1 or Pile 2 is clicked on while (true) { - final Object o = GuiUtils.chooseOne("Choose a pile", disp); + final Object o = GuiChoose.one("Choose a pile", disp); final Card c = (Card) o; String name = c.getName(); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java index fb2c76c9ce7..77cba573e03 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java @@ -43,7 +43,7 @@ import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.item.CardDb; import forge.util.MyRandom; @@ -816,7 +816,7 @@ public final class AbilityFactoryCopy { } else { num = Integer.toString(multi - 1) + "th"; } - chosenSAtmp = GuiUtils.chooseOne("Select " + num + " spell to copy to stack", tgtSpells); + chosenSAtmp = GuiChoose.one("Select " + num + " spell to copy to stack", tgtSpells); chosenSAs.add(chosenSAtmp); tgtSpells.remove(chosenSAtmp); } else { @@ -836,7 +836,7 @@ public final class AbilityFactoryCopy { if (tgtSpells.size() == 1) { chosenSA = tgtSpells.get(0); } else if (sa.getActivatingPlayer().isHuman()) { - chosenSA = (SpellAbility) GuiUtils.chooseOne("Select a spell to copy", tgtSpells); + chosenSA = (SpellAbility) GuiChoose.one("Select a spell to copy", tgtSpells); } else { chosenSA = tgtSpells.get(0); } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java index 3f15dda9444..55607308cd0 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java @@ -47,7 +47,7 @@ import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.match.CMatchUI; import forge.util.MyRandom; @@ -731,7 +731,7 @@ public class AbilityFactoryCounters { for (int j = 0; j <= counterAmount; j++) { integers[j] = Integer.valueOf(j); } - final Integer i = GuiUtils.chooseOneOrNone("How many counters?", integers); + final Integer i = GuiChoose.oneOrNone("How many counters?", integers); if (null == i) { return; } else { @@ -1194,7 +1194,7 @@ public class AbilityFactoryCounters { } if (typeChoices.size() > 1) { String prompt = "Select type counters to remove"; - chosenType = GuiUtils.chooseOne(prompt, typeChoices); + chosenType = GuiChoose.one(prompt, typeChoices); } else { chosenType = typeChoices.get(0); @@ -1211,7 +1211,7 @@ public class AbilityFactoryCounters { choices.add(Integer.valueOf(i)); } String prompt = "Select the number of " + chosenType.getName() + " counters to remove"; - chosenAmount = GuiUtils.chooseOne(prompt, choices); + chosenAmount = GuiChoose.one(prompt, choices); } } else { @@ -1246,7 +1246,7 @@ public class AbilityFactoryCounters { choices.add("" + i); } final String prompt = "Select the number of " + type + " counters to remove"; - final String o = GuiUtils.chooseOne(prompt, choices); + final String o = GuiChoose.one(prompt, choices); counterAmount = Integer.parseInt((String) o); } } @@ -1550,7 +1550,7 @@ public class AbilityFactoryCounters { } if (choices.size() > 0) { card.addCounter( - Counters.getType((choices.size() == 1 ? choices.get(0) : GuiUtils.chooseOne( + Counters.getType((choices.size() == 1 ? choices.get(0) : GuiChoose.one( "Select counter type", choices).toString())), 1); } } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java index 83ce307e308..6da9c4be1b9 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java @@ -41,7 +41,7 @@ import forge.control.input.InputPayManaCostUtil; import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.util.MyRandom; /** @@ -351,7 +351,7 @@ public class AbilityFactoryMana { } for (int nMana = 1; nMana <= amount; nMana++) { String choice = ""; - Object o = GuiUtils.chooseOne("Select Mana to Produce", colorMenu); + Object o = GuiChoose.one("Select Mana to Produce", colorMenu); if (o == null) { final StringBuilder sb = new StringBuilder(); sb.append("AbilityFactoryMana::manaResolve() - Human color mana choice is empty for "); @@ -376,7 +376,7 @@ public class AbilityFactoryMana { chosen = CardFactoryUtil.getMostProminentColor(AllZone.getComputerPlayer().getCardsIn( ZoneType.Hand)); } - GuiUtils.chooseOne("Computer picked: ", new String[]{chosen}); + GuiChoose.one("Computer picked: ", new String[]{chosen}); abMana.setExpressChoice(InputPayManaCostUtil.getShortColorString(chosen)); } if (abMana.getExpressChoice().isEmpty()) { @@ -411,7 +411,7 @@ public class AbilityFactoryMana { else { colorMenu = Constant.Color.ONLY_COLORS; } - String s = GuiUtils.chooseOne("Select Mana to Produce", colorMenu); + String s = GuiChoose.one("Select Mana to Produce", colorMenu); if (s == null) { final StringBuilder sb = new StringBuilder(); sb.append("AbilityFactoryMana::manaResolve() - Human color mana choice is empty for "); @@ -431,7 +431,7 @@ public class AbilityFactoryMana { chosen = CardFactoryUtil.getMostProminentColor(AllZone.getComputerPlayer().getCardsIn( ZoneType.Hand)); } - GuiUtils.chooseOne("Computer picked: ", new String[]{chosen}); + GuiChoose.one("Computer picked: ", new String[]{chosen}); abMana.setExpressChoice(InputPayManaCostUtil.getShortColorString(chosen)); } if (abMana.getExpressChoice().isEmpty()) { @@ -925,7 +925,7 @@ public class AbilityFactoryMana { baseMana = InputPayManaCostUtil.getShortColorString(colors.get(0)); } else { if (player.isHuman()) { - final Object o = GuiUtils.chooseOneOrNone("Select Mana to Produce", colors); + final Object o = GuiChoose.oneOrNone("Select Mana to Produce", colors); if (o == null) { // User hit cancel abMana.setCanceled(true); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java index a972a9bbc74..8218a7420bc 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java @@ -46,7 +46,7 @@ import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.util.MyRandom; @@ -2244,7 +2244,7 @@ public class AbilityFactoryPermanentState { if (AllZoneUtil.isCardInPlay(tgtC) && ((tgt == null) || tgtC.canBeTargetedBy(sa))) { if (sa.getActivatingPlayer().isHuman()) { final String[] tapOrUntap = new String[] { "Tap", "Untap" }; - final Object z = GuiUtils.chooseOneOrNone("Tap or Untap " + tgtC + "?", tapOrUntap); + final Object z = GuiChoose.oneOrNone("Tap or Untap " + tgtC + "?", tapOrUntap); if (null == z) { continue; } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java index 0ebf6e972aa..0bad644894f 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java @@ -45,7 +45,7 @@ import forge.card.spellability.Target; import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.util.MyRandom; /** @@ -392,7 +392,7 @@ public final class AbilityFactoryPlay { Card tgtCard = tgtCards.get(0); if (tgtCards.size() > 1) { if (controller.isHuman()) { - tgtCard = GuiUtils.chooseOne("Select a card to play", tgtCards); + tgtCard = GuiChoose.one("Select a card to play", tgtCards); } else { // AI tgtCards = tgtCards.filter(new Predicate() { @@ -468,7 +468,7 @@ public final class AbilityFactoryPlay { if (sas.size() == 1) { tgtSA = sas.get(0); } else if (sa.getActivatingPlayer().isHuman()) { - tgtSA = GuiUtils.chooseOne("Select a spell to cast", sas); + tgtSA = GuiChoose.one("Select a spell to cast", sas); } else { tgtSA = sas.get(0); } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java index 29b4e664cc2..ec529dbc498 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java @@ -47,7 +47,7 @@ import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; /** @@ -731,7 +731,7 @@ public final class AbilityFactoryProtection { final ArrayList gains = new ArrayList(); if (isChoice) { if (sa.getActivatingPlayer().isHuman()) { - final String choice = GuiUtils.chooseOne("Choose a protection", choices); + final String choice = GuiChoose.one("Choose a protection", choices); if (null == choice) { return; } @@ -1161,7 +1161,7 @@ public final class AbilityFactoryProtection { final ArrayList gains = new ArrayList(); if (isChoice) { if (sa.getActivatingPlayer().isHuman()) { - final String choice = GuiUtils.chooseOne("Choose a protection", choices); + final String choice = GuiChoose.one("Choose a protection", choices); if (null == choice) { return; } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java index b2f18204ebe..a9de6dac4b0 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java @@ -48,7 +48,7 @@ import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.util.MyRandom; /** @@ -438,7 +438,7 @@ public final class AbilityFactoryReveal { boolean cardsRevealed = false; if (params.containsKey("Reveal")) { - GuiUtils.chooseOne("Revealing cards from library", top); + GuiChoose.one("Revealing cards from library", top); cardsRevealed = true; // Singletons.getModel().getGameAction().revealToCopmuter(top.toArray()); // - for when it exists @@ -448,18 +448,18 @@ public final class AbilityFactoryReveal { question += c + " "; } if (p.isHuman() && GameActionUtil.showYesNoDialog(host, question)) { - GuiUtils.chooseOne(host + "Revealing cards from library", top); + GuiChoose.one(host + "Revealing cards from library", top); // Singletons.getModel().getGameAction().revealToCopmuter(top.toArray()); cardsRevealed = true; } else if (p.isComputer() && (top.get(0).isInstant() || top.get(0).isSorcery())) { - GuiUtils.chooseOne(host + "Revealing cards from library", top); + GuiChoose.one(host + "Revealing cards from library", top); cardsRevealed = true; } } else if (params.containsKey("RevealValid")) { final String revealValid = params.get("RevealValid"); final CardList toReveal = top.getValidCards(revealValid, host.getController(), host); if (!toReveal.isEmpty()) { - GuiUtils.chooseOne("Revealing cards from library", toReveal); + GuiChoose.one("Revealing cards from library", toReveal); if (params.containsKey("RememberRevealed")) { for (final Card one : toReveal) { host.addRemembered(one); @@ -470,7 +470,7 @@ public final class AbilityFactoryReveal { // - for when it exists } else if (choser.isHuman()) { // show the user the revealed cards - GuiUtils.chooseOne("Looking at cards from library", top); + GuiChoose.one("Looking at cards from library", top); cardsRevealed = true; } @@ -527,9 +527,9 @@ public final class AbilityFactoryReveal { prompt = "Chose a card to put on top of the "; } if (anyNumber || optional) { - chosen = GuiUtils.chooseOneOrNone(prompt + destZone1, valid); + chosen = GuiChoose.oneOrNone(prompt + destZone1, valid); } else { - chosen = GuiUtils.chooseOne(prompt + destZone1, valid); + chosen = GuiChoose.one(prompt + destZone1, valid); } if ((chosen == null) || chosen.getName().equals("[No valid cards]")) { break; @@ -563,7 +563,7 @@ public final class AbilityFactoryReveal { break; } if (changeValid.length() > 0) { - GuiUtils.chooseOne("Computer picked: ", chosen); + GuiChoose.one("Computer picked: ", chosen); } movedCards.add(chosen); valid.remove(chosen); @@ -629,7 +629,7 @@ public final class AbilityFactoryReveal { if (libraryPosition2 == -1) { prompt = "Put the rest on the bottom of the library in any order"; } - chosen = GuiUtils.chooseOne(prompt, rest); + chosen = GuiChoose.one(prompt, rest); } else { chosen = rest.get(0); } @@ -1050,7 +1050,7 @@ public final class AbilityFactoryReveal { } if (revealed.size() > 0) { - GuiUtils.chooseOne(p + " revealed: ", revealed); + GuiChoose.one(p + " revealed: ", revealed); } // TODO Allow Human to choose the order @@ -1428,7 +1428,7 @@ public final class AbilityFactoryReveal { final CardList hand = p.getCardsIn(ZoneType.Hand); if (sa.getActivatingPlayer().isHuman()) { if (hand.size() > 0) { - GuiUtils.chooseOne(p + "'s hand", hand); + GuiChoose.one(p + "'s hand", hand); } else { final StringBuilder sb = new StringBuilder(); sb.append(p).append("'s hand is empty!"); @@ -2054,7 +2054,7 @@ public final class AbilityFactoryReveal { topCards.add(lib.get(j)); } - List orderedCards = GuiUtils.getOrderChoices("Select order to Rearrange", "Top of Library", 0, topCards.toArray(), null); + List orderedCards = GuiChoose.getOrderChoices("Select order to Rearrange", "Top of Library", 0, topCards.toArray(), null); for (int i = maxCards - 1; i >= 0; i--) { Card next = (Card) orderedCards.get(i); Singletons.getModel().getGameAction().moveToLibrary(next, 0); @@ -2377,7 +2377,7 @@ public final class AbilityFactoryReveal { final CardList revealed = new CardList(); if (params.containsKey("Random")) { revealed.add(CardUtil.getRandom(handChoices)); - GuiUtils.chooseOneOrNone("Revealed card(s)", revealed); + GuiChoose.oneOrNone("Revealed card(s)", revealed); } else { CardList valid = new CardList(handChoices); int max = 1; @@ -2389,7 +2389,7 @@ public final class AbilityFactoryReveal { } revealed.addAll(AbilityFactoryReveal.getRevealedList(sa.getActivatingPlayer(), valid, max, anyNumber)); if (sa.getActivatingPlayer().isComputer()) { - GuiUtils.chooseOneOrNone("Revealed card(s)", revealed); + GuiChoose.oneOrNone("Revealed card(s)", revealed); } } @@ -2418,7 +2418,7 @@ public final class AbilityFactoryReveal { final int validamount = Math.min(valid.size(), max); if (anyNumber && player.isHuman() && validamount > 0) { - final List selection = GuiUtils.getOrderChoices("Choose Which Cards to Reveal", "Revealed", -1, valid.toArray(), null); + final List selection = GuiChoose.getOrderChoices("Choose Which Cards to Reveal", "Revealed", -1, valid.toArray(), null); for (final Object o : selection) { if (o != null && o instanceof Card) { chosen.add((Card) o); @@ -2427,7 +2427,7 @@ public final class AbilityFactoryReveal { } else { for (int i = 0; i < validamount; i++) { if (player.isHuman()) { - final Card o = GuiUtils.chooseOne("Choose card(s) to reveal", valid); + final Card o = GuiChoose.one("Choose card(s) to reveal", valid); if (o != null) { chosen.add(o); valid.remove(o); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java b/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java index f14c527e771..e13935b6317 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java @@ -38,7 +38,7 @@ import forge.card.spellability.Target; import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.util.MyRandom; /** @@ -566,9 +566,9 @@ public class AbilityFactorySacrifice { } Object o; if (optional) { - o = GuiUtils.chooseOneOrNone("Select a card to sacrifice", list); + o = GuiChoose.oneOrNone("Select a card to sacrifice", list); } else { - o = GuiUtils.chooseOne("Select a card to sacrifice", list); + o = GuiChoose.one("Select a card to sacrifice", list); } if (o != null) { final Card c = (Card) o; diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java index 83898846410..383ee0b02b8 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java @@ -45,7 +45,7 @@ import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.util.MyRandom; /** @@ -623,7 +623,7 @@ public class AbilityFactoryZoneAffecting { } else { final CardList drawn = p.drawCards(numCards); if (params.containsKey("Reveal")) { - GuiUtils.chooseOne("Revealing drawn cards", drawn); + GuiChoose.one("Revealing drawn cards", drawn); } if (params.containsKey("RememberDrawn")) { for (final Card c : drawn) { @@ -1345,7 +1345,7 @@ public class AbilityFactoryZoneAffecting { if (p.isHuman()) { // "reveal to computer" for information gathering } else { - GuiUtils.chooseOneOrNone("Revealed computer hand", dPHand); + GuiChoose.oneOrNone("Revealed computer hand", dPHand); } String valid = params.get("DiscardValid"); @@ -1394,7 +1394,7 @@ public class AbilityFactoryZoneAffecting { max = Math.min(max, numCards); CardList list = ComputerUtil.discardNumTypeAI(max, dValid, sa); if (mode.startsWith("Reveal")) { - GuiUtils.chooseOneOrNone("Computer has chosen", list); + GuiChoose.oneOrNone("Computer has chosen", list); } discarded.addAll(list); for (Card card : list) { @@ -1427,7 +1427,7 @@ public class AbilityFactoryZoneAffecting { if (mode.startsWith("Reveal")) { final CardList dCs = new CardList(); dCs.add(dC); - GuiUtils.chooseOneOrNone("Computer has chosen", dCs); + GuiChoose.oneOrNone("Computer has chosen", dCs); } discarded.add(dC); p.discard(dC, sa); @@ -1436,16 +1436,16 @@ public class AbilityFactoryZoneAffecting { } else { // human if (mode.startsWith("Reveal")) { - GuiUtils.chooseOneOrNone("Revealed " + p + " hand", dPHand); + GuiChoose.oneOrNone("Revealed " + p + " hand", dPHand); } for (int i = 0; i < numCards; i++) { if (dPChHand.size() > 0) { Card dC = null; if (params.containsKey("Optional")) { - dC = GuiUtils.chooseOneOrNone("Choose a card to be discarded", dPChHand); + dC = GuiChoose.oneOrNone("Choose a card to be discarded", dPChHand); } else { - dC = GuiUtils.chooseOne("Choose a card to be discarded", dPChHand); + dC = GuiChoose.one("Choose a card to be discarded", dPChHand); } if (dC != null) { dPChHand.remove(dC); discarded.add(dC); diff --git a/src/main/java/forge/card/cardfactory/CardFactoryArtifacts.java b/src/main/java/forge/card/cardfactory/CardFactoryArtifacts.java index 6bd0a394c03..ca10843584f 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryArtifacts.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryArtifacts.java @@ -21,7 +21,7 @@ import forge.control.input.Input; import forge.game.player.Player; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.match.CMatchUI; import forge.view.ButtonUtil; @@ -59,7 +59,7 @@ class CardFactoryArtifacts { imageName = "B 1 1 Thrull"; color = "B"; } else if (player.isHuman()) { - final Object q = GuiUtils.chooseOneOrNone("Select type of creature", choices); + final Object q = GuiChoose.oneOrNone("Select type of creature", choices); if (q != null) { if (q.equals("Citizen")) { type = "Citizen"; @@ -272,7 +272,7 @@ class CardFactoryArtifacts { } } } // while - GuiUtils.chooseOneOrNone("Revealed cards:", revealed); + GuiChoose.oneOrNone("Revealed cards:", revealed); for (final Card revealedCard : revealed) { Singletons.getModel().getGameAction().moveToBottomOfLibrary(revealedCard); } @@ -361,7 +361,7 @@ class CardFactoryArtifacts { if (i == 4) { title = "Put fourth from top of library: "; } - final Object o = GuiUtils.chooseOneOrNone(title, lands); + final Object o = GuiChoose.oneOrNone(title, lands); if (o == null) { break; } @@ -505,7 +505,7 @@ class CardFactoryArtifacts { for (int j = 0; j <= num; j++) { choices[j] = "" + j; } - final String answer = (GuiUtils.chooseOneOrNone("Life to pay:", choices)); + final String answer = (GuiChoose.oneOrNone("Life to pay:", choices)); lifeToPay = Integer.parseInt(answer); } else { // not implemented for Compy @@ -590,7 +590,7 @@ class CardFactoryArtifacts { // Then look at the exiled cards and put them on // top of your library in any order. while (this.exiled.size() > 0) { - final Card c1 = GuiUtils.chooseOne("Put a card on top of your library.", this.exiled); + final Card c1 = GuiChoose.one("Put a card on top of your library.", this.exiled); Singletons.getModel().getGameAction().moveToLibrary(c1); this.exiled.remove(c1); } diff --git a/src/main/java/forge/card/cardfactory/CardFactoryAuras.java b/src/main/java/forge/card/cardfactory/CardFactoryAuras.java index 21b4fc59a7e..909c656cb76 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryAuras.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryAuras.java @@ -41,7 +41,7 @@ import forge.card.spellability.Target; import forge.control.input.Input; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; /** @@ -126,7 +126,7 @@ class CardFactoryAuras { public void resolve() { // Only query player, AI will have decided already. if (card.getController().isHuman()) { - newType[0] = GuiUtils.chooseOne("Select land type.", CardUtil.getLandTypes()); + newType[0] = GuiChoose.one("Select land type.", CardUtil.getLandTypes()); } Singletons.getModel().getGameAction().moveToPlay(card); diff --git a/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java b/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java index 390401eb2a9..d012b713c29 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java @@ -55,7 +55,7 @@ import forge.control.input.Input; import forge.game.player.Player; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.match.CMatchUI; import forge.util.Aggregates; import forge.view.ButtonUtil; @@ -218,7 +218,7 @@ public class CardFactoryCreatures { .filter(CardPredicates.Presets.ARTIFACTS); if (artifacts.size() != 0) { - final Card c = GuiUtils.chooseOne("Select an artifact put a phylactery counter on", artifacts); + final Card c = GuiChoose.one("Select an artifact put a phylactery counter on", artifacts); if (c != null) { c.addCounter(Counters.PHYLACTERY, 1); } @@ -310,7 +310,7 @@ public class CardFactoryCreatures { if (card.getController().isHuman()) { final String[] colors = Constant.Color.ONLY_COLORS; - final Object o = GuiUtils.chooseOne("Choose color", colors); + final Object o = GuiChoose.one("Choose color", colors); color[0] = (String) o; } else { // AI chooses the color that appears in the keywords of @@ -465,7 +465,7 @@ public class CardFactoryCreatures { int lifeGain = 0; if (card.getController().isHuman()) { final String[] choices = { "white", "blue", "black", "red", "green" }; - final Object o = GuiUtils.chooseOneOrNone("Select Color: ", choices); + final Object o = GuiChoose.oneOrNone("Select Color: ", choices); Log.debug("Treva, the Renewer", "Color:" + o); lifeGain = CardFactoryUtil.getNumberOfPermanentsByColor((String) o); @@ -509,7 +509,7 @@ public class CardFactoryCreatures { final CardList cl = new CardList(); cl.add(lib.get(0)); - GuiUtils.chooseOneOrNone("Top card", cl); + GuiChoose.oneOrNone("Top card", cl); } @Override @@ -985,7 +985,7 @@ public class CardFactoryCreatures { if (card.getController().isHuman()) { if (creats.size() > 0) { - final List selection = GuiUtils.chooseNoneOrMany("Select creatures to sacrifice", creats); + final List selection = GuiChoose.noneOrMany("Select creatures to sacrifice", creats); numCreatures[0] = selection.size(); for (int m = 0; m < selection.size(); m++) { @@ -1063,7 +1063,7 @@ public class CardFactoryCreatures { life[i] = String.valueOf(i); } - final Object o = GuiUtils.chooseOne("Nameless Race - pay X life", life); + final Object o = GuiChoose.one("Nameless Race - pay X life", life); final String answer = (String) o; int loseLife = 0; try { @@ -1334,9 +1334,9 @@ public class CardFactoryCreatures { hand.remove(random); } if (!revealed.isEmpty()) { - GuiUtils.chooseOne("Revealed at random", revealed); + GuiChoose.one("Revealed at random", revealed); } else { - GuiUtils.chooseOne("Revealed at random", new String[] { "Nothing to reveal" }); + GuiChoose.one("Revealed at random", new String[] { "Nothing to reveal" }); } for (final Card c : revealed) { diff --git a/src/main/java/forge/card/cardfactory/CardFactoryEnchantments.java b/src/main/java/forge/card/cardfactory/CardFactoryEnchantments.java index 61038b99a07..2e855a69a91 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryEnchantments.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryEnchantments.java @@ -17,7 +17,7 @@ import forge.game.GameLossReason; import forge.game.player.Player; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.match.CMatchUI; import forge.view.ButtonUtil; import forge.CardPredicates; @@ -99,12 +99,12 @@ class CardFactoryEnchantments { chooseGrave.addAll(grave); } - final Card c = GuiUtils.chooseOne("Choose first creature to exile", chooseGrave); + final Card c = GuiChoose.one("Choose first creature to exile", chooseGrave); if (c != null) { CardList newGrave = c.getOwner().getCardsIn(ZoneType.Graveyard).filter(CardPredicates.Presets.CREATURES); newGrave.remove(c); - final Object o2 = GuiUtils.chooseOne("Choose second creature to exile", newGrave); + final Object o2 = GuiChoose.one("Choose second creature to exile", newGrave); if (o2 != null) { final Card c2 = (Card) o2; newGrave.remove(c2); diff --git a/src/main/java/forge/card/cardfactory/CardFactoryInstants.java b/src/main/java/forge/card/cardfactory/CardFactoryInstants.java index 9d26ff9acf1..9840570d5cc 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryInstants.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryInstants.java @@ -41,7 +41,7 @@ import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.util.MyRandom; @@ -130,7 +130,7 @@ public class CardFactoryInstants { final CardList libraryList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); final CardList selectedCards = new CardList(); - Object o = GuiUtils.chooseOneOrNone("Select first card", libraryList); + Object o = GuiChoose.oneOrNone("Select first card", libraryList); if (o != null) { final Card c1 = (Card) o; libraryList.remove(c1); @@ -138,7 +138,7 @@ public class CardFactoryInstants { } else { return; } - o = GuiUtils.chooseOneOrNone("Select second card", libraryList); + o = GuiChoose.oneOrNone("Select second card", libraryList); if (o != null) { final Card c2 = (Card) o; libraryList.remove(c2); @@ -146,7 +146,7 @@ public class CardFactoryInstants { } else { return; } - o = GuiUtils.chooseOneOrNone("Select third card", libraryList); + o = GuiChoose.oneOrNone("Select third card", libraryList); if (o != null) { final Card c3 = (Card) o; libraryList.remove(c3); @@ -194,7 +194,7 @@ public class CardFactoryInstants { // NOTE: Using getChoiceOptional() results in a null error // when you click on Cancel. - final Card choice = GuiUtils.chooseOne("Select card to give to computer", selectedCards); + final Card choice = GuiChoose.one("Select card to give to computer", selectedCards); selectedCards.remove(choice); Singletons.getModel().getGameAction().moveToHand(choice); @@ -238,7 +238,7 @@ public class CardFactoryInstants { if (player.isHuman()) { for (int i = 0; i < x; i++) { - final Object o = GuiUtils.chooseOne("Remove from game", graveList); + final Object o = GuiChoose.one("Remove from game", graveList); if (o == null) { break; } @@ -390,7 +390,7 @@ public class CardFactoryInstants { } for (int i = 0; (i < 3) && !choices.isEmpty(); i++) { - final Object o = GuiUtils.chooseOne(this.prompt[i], choices); + final Object o = GuiChoose.one(this.prompt[i], choices); final Card c1 = (Card) o; if (i == 0) { Singletons.getModel().getGameAction().moveToHand(c1); @@ -477,12 +477,12 @@ public class CardFactoryInstants { @Override public void resolve() { final String[] choices = new String[] { "Artifact", "Creature", "Land" }; - final Object o = GuiUtils.chooseOne("Select permanent type", choices); + final Object o = GuiChoose.one("Select permanent type", choices); final String cardType = (String) o; final CardList list = this.getTargetPlayer().getCardsIn(ZoneType.Battlefield).getType(cardType); final String[] tapOrUntap = new String[] { "Tap", "Untap" }; - final Object z = GuiUtils.chooseOne("Tap or Untap?", tapOrUntap); + final Object z = GuiChoose.one("Tap or Untap?", tapOrUntap); final boolean tap = (z.equals("Tap")) ? true : false; for (final Card c : list) { diff --git a/src/main/java/forge/card/cardfactory/CardFactorySorceries.java b/src/main/java/forge/card/cardfactory/CardFactorySorceries.java index e4291c0fb99..ae106146fc1 100644 --- a/src/main/java/forge/card/cardfactory/CardFactorySorceries.java +++ b/src/main/java/forge/card/cardfactory/CardFactorySorceries.java @@ -54,7 +54,7 @@ import forge.game.player.Player; import forge.game.player.PlayerUtil; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.match.CMatchUI; import forge.view.ButtonUtil; @@ -120,12 +120,12 @@ public class CardFactorySorceries { final StringBuilder msg = new StringBuilder(); msg.append("Revealing top ").append(count).append(" cards of library: "); - GuiUtils.chooseOne(msg.toString(), cards); + GuiChoose.one(msg.toString(), cards); // Human chooses if (card.getController().isComputer()) { for (int i = 0; i < count; i++) { if (!stop) { - choice = GuiUtils.chooseOneOrNone("Choose cards to put into the first pile: ", + choice = GuiChoose.oneOrNone("Choose cards to put into the first pile: ", cards); if (choice != null) { pile1.add(choice); @@ -234,7 +234,7 @@ public class CardFactorySorceries { final int numChosen = chosen.size(); for (int i = 0; i < numChosen; i++) { - final Card check = GuiUtils.chooseOneOrNone("Select spells to play in reverse order: ", chosen); + final Card check = GuiChoose.oneOrNone("Select spells to play in reverse order: ", chosen); if (check == null) { break; } @@ -1145,7 +1145,7 @@ public class CardFactorySorceries { final int num = CardFactoryUtil.getNumberOfManaSymbolsByColor("U", topCards); final StringBuilder sb = new StringBuilder(); sb.append("Revealed cards - ").append(num).append(" U mana symbols"); - GuiUtils.chooseOneOrNone(sb.toString(), topCards); + GuiChoose.oneOrNone(sb.toString(), topCards); // opponent moves this many cards to graveyard opp.mill(num); @@ -1397,7 +1397,7 @@ public class CardFactorySorceries { } }); - final Card check = GuiUtils.chooseOneOrNone("Select target creature with CMC < X", grave); + final Card check = GuiChoose.oneOrNone("Select target creature with CMC < X", grave); if (check != null) { final Card c = (Card) check; if (c.canBeTargetedBy(spell)) { @@ -1482,7 +1482,7 @@ public class CardFactorySorceries { for (int i = 0; i <= max; i++) { choices[i] = Integer.valueOf(i); } - final Integer answer = GuiUtils.chooseOne("Choose X", choices); + final Integer answer = GuiChoose.one("Choose X", choices); // everything stops here if user cancelled if (answer == null) { this.stop(); @@ -1567,14 +1567,14 @@ public class CardFactorySorceries { private ArrayList chooseTwo(final ArrayList choices) { final ArrayList out = new ArrayList(); - Object o = GuiUtils.chooseOneOrNone("Choose Two", choices); + Object o = GuiChoose.oneOrNone("Choose Two", choices); if (o == null) { return null; } out.add((String) o); choices.remove(out.get(0)); - o = GuiUtils.chooseOneOrNone("Choose Two", choices); + o = GuiChoose.oneOrNone("Choose Two", choices); if (o == null) { return null; } @@ -1620,7 +1620,7 @@ public class CardFactorySorceries { // Sacrifice an artifact CardList arts = p.getCardsIn(ZoneType.Battlefield); arts = arts.filter(Presets.ARTIFACTS); - final Object toSac = GuiUtils.chooseOneOrNone("Sacrifice an artifact", arts); + final Object toSac = GuiChoose.oneOrNone("Sacrifice an artifact", arts); if (toSac != null) { final Card c = (Card) toSac; baseCMC = CardUtil.getConvertedManaCost(c); @@ -1631,9 +1631,9 @@ public class CardFactorySorceries { // Search your library for an artifact final CardList lib = p.getCardsIn(ZoneType.Library); - GuiUtils.chooseOneOrNone("Looking at Library", lib); + GuiChoose.oneOrNone("Looking at Library", lib); final CardList libArts = lib.filter(Presets.ARTIFACTS); - final Object o = GuiUtils.chooseOneOrNone("Search for artifact", libArts); + final Object o = GuiChoose.oneOrNone("Search for artifact", libArts); if (o != null) { newArtifact[0] = (Card) o; } else { diff --git a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java index c429aebef82..446762950ee 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java @@ -75,7 +75,7 @@ import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.match.CMatchUI; import forge.util.Aggregates; import forge.util.MyRandom; @@ -1059,7 +1059,7 @@ public class CardFactoryUtil { return; } - final Card o = GuiUtils.chooseOneOrNone("Select a card", sameCost); + final Card o = GuiChoose.oneOrNone("Select a card", sameCost); if (o != null) { // ability.setTargetCard((Card)o); @@ -1267,7 +1267,7 @@ public class CardFactoryUtil { question.append(manacost).append(" or less from your graveyard to your hand?"); if (GameActionUtil.showYesNoDialog(sourceCard, question.toString())) { - final Card o = GuiUtils.chooseOneOrNone("Select a card", sameCost); + final Card o = GuiChoose.oneOrNone("Select a card", sameCost); if (o != null) { final Card c1 = (Card) o; @@ -4914,7 +4914,7 @@ public class CardFactoryUtil { card.clearDevoured(); if (card.getController().isHuman()) { if (creats.size() > 0) { - final List selection = GuiUtils.getOrderChoices("Devour", "Devouring", -1, creats.toArray(), null); + final List selection = GuiChoose.getOrderChoices("Devour", "Devouring", -1, creats.toArray(), null); numCreatures[0] = selection.size(); for (Object o : selection) { diff --git a/src/main/java/forge/card/cost/CostExile.java b/src/main/java/forge/card/cost/CostExile.java index 873949334d3..46e17cf519c 100644 --- a/src/main/java/forge/card/cost/CostExile.java +++ b/src/main/java/forge/card/cost/CostExile.java @@ -35,7 +35,7 @@ import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.match.CMatchUI; import forge.view.ButtonUtil; @@ -345,8 +345,8 @@ public class CostExile extends CostPartWithList { this.cancel(); } - final Card o = GuiUtils - .chooseOneOrNone("Exile from " + part.getFrom(), this.typeList); + final Card o = GuiChoose + .oneOrNone("Exile from " + part.getFrom(), this.typeList); if (o != null) { final Card c = (Card) o; @@ -432,8 +432,7 @@ public class CostExile extends CostPartWithList { } //Have to use the stack descriptions here because some copied spells have no description otherwise - final String o = GuiUtils - .chooseOneOrNone("Exile from " + part.getFrom(), this.descList); + final String o = GuiChoose.oneOrNone("Exile from " + part.getFrom(), this.descList); if (o != null) { final SpellAbility toExile = this.saList.get(descList.indexOf(o)); diff --git a/src/main/java/forge/card/cost/CostRemoveCounter.java b/src/main/java/forge/card/cost/CostRemoveCounter.java index cfe15e6dbda..346aff0d70d 100644 --- a/src/main/java/forge/card/cost/CostRemoveCounter.java +++ b/src/main/java/forge/card/cost/CostRemoveCounter.java @@ -26,7 +26,7 @@ import forge.control.input.Input; import forge.game.player.Player; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.match.CMatchUI; import forge.view.ButtonUtil; @@ -418,8 +418,8 @@ public class CostRemoveCounter extends CostPartWithList { this.cancel(); } - final Card o = GuiUtils - .chooseOneOrNone("Remove counter(s) from a card in " + costRemoveCounter.getZone(), this.typeList); + final Card o = GuiChoose + .oneOrNone("Remove counter(s) from a card in " + costRemoveCounter.getZone(), this.typeList); if (o != null) { final Card card = (Card) o; diff --git a/src/main/java/forge/card/cost/CostReveal.java b/src/main/java/forge/card/cost/CostReveal.java index 618081ff57c..d646e451ebb 100644 --- a/src/main/java/forge/card/cost/CostReveal.java +++ b/src/main/java/forge/card/cost/CostReveal.java @@ -27,7 +27,7 @@ import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.match.CMatchUI; import forge.view.ButtonUtil; @@ -133,7 +133,7 @@ public class CostReveal extends CostPartWithList { */ @Override public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) { - GuiUtils.chooseOneOrNone("Revealed cards:", this.getList()); + GuiChoose.oneOrNone("Revealed cards:", this.getList()); } /* diff --git a/src/main/java/forge/card/cost/CostUtil.java b/src/main/java/forge/card/cost/CostUtil.java index eac6bab8d65..3ac14c881e5 100644 --- a/src/main/java/forge/card/cost/CostUtil.java +++ b/src/main/java/forge/card/cost/CostUtil.java @@ -30,7 +30,7 @@ import forge.control.input.Input; import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; /** * The Class CostUtil. @@ -410,7 +410,7 @@ public class CostUtil { for (int i = 0; i < choiceArray.length; i++) { choiceArray[i] = i; } - final Integer chosenX = GuiUtils.chooseOne(card.toString() + " - Choose a Value for X", choiceArray); + final Integer chosenX = GuiChoose.one(card.toString() + " - Choose a Value for X", choiceArray); sa.setSVar("ChosenX", "Number$" + Integer.toString(chosenX)); card.setSVar("ChosenX", "Number$" + Integer.toString(chosenX)); @@ -438,7 +438,7 @@ public class CostUtil { for (int i = 0; i < choiceArray.length; i++) { choiceArray[i] = Integer.valueOf(i); } - final Integer chosenY = GuiUtils.chooseOne(card.toString() + " - Choose a Value for Y", choiceArray); + final Integer chosenY = GuiChoose.one(card.toString() + " - Choose a Value for Y", choiceArray); sa.setSVar("ChosenY", "Number$" + Integer.toString(chosenY)); card.setSVar("ChosenY", "Number$" + Integer.toString(chosenY)); diff --git a/src/main/java/forge/card/mana/ManaPool.java b/src/main/java/forge/card/mana/ManaPool.java index 53a0ad69302..eabf5788d1c 100644 --- a/src/main/java/forge/card/mana/ManaPool.java +++ b/src/main/java/forge/card/mana/ManaPool.java @@ -28,7 +28,7 @@ import forge.card.spellability.AbilityMana; import forge.card.spellability.SpellAbility; import forge.control.input.InputPayManaCostUtil; import forge.game.player.Player; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; /** *

@@ -331,7 +331,7 @@ public class ManaPool { Object o; if (this.owner.isHuman()) { - o = GuiUtils.chooseOneOrNone("Pay Mana from Mana Pool", alChoice); + o = GuiChoose.oneOrNone("Pay Mana from Mana Pool", alChoice); } else { o = alChoice.get(0); // owner is computer } diff --git a/src/main/java/forge/card/replacement/ReplacementHandler.java b/src/main/java/forge/card/replacement/ReplacementHandler.java index 065c31a9f21..072520a86a6 100644 --- a/src/main/java/forge/card/replacement/ReplacementHandler.java +++ b/src/main/java/forge/card/replacement/ReplacementHandler.java @@ -31,7 +31,7 @@ import forge.card.spellability.SpellAbility; import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; /** * TODO: Write javadoc for this type. @@ -127,7 +127,7 @@ public class ReplacementHandler { if (possibleReplacers.size() > 1) { if (decider.isHuman()) { - chosenRE = GuiUtils.chooseOne("Choose which replacement effect to apply.", + chosenRE = GuiChoose.one("Choose which replacement effect to apply.", possibleReplacers); } else { // AI logic for choosing which replacement effect to apply diff --git a/src/main/java/forge/card/spellability/TargetSelection.java b/src/main/java/forge/card/spellability/TargetSelection.java index 4d94538f829..067c0c7c61d 100644 --- a/src/main/java/forge/card/spellability/TargetSelection.java +++ b/src/main/java/forge/card/spellability/TargetSelection.java @@ -32,7 +32,7 @@ import forge.control.input.Input; import forge.game.player.Player; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.match.CMatchUI; import forge.view.ButtonUtil; @@ -509,7 +509,7 @@ public class TargetSelection { choicesWithDone.add(dummy); } - final Card check = GuiUtils.chooseOneOrNone(message, choicesWithDone); + final Card check = GuiChoose.oneOrNone(message, choicesWithDone); if (check != null) { final Card c = (Card) check; if (!c.equals(divBattlefield) && !c.equals(divExile) && !c.equals(divGrave) @@ -562,7 +562,7 @@ public class TargetSelection { if (choices.length == 0) { select.setCancel(true); } else { - final String madeChoice = GuiUtils.chooseOneOrNone(message, choices); + final String madeChoice = GuiChoose.oneOrNone(message, choices); if (madeChoice != null) { if (madeChoice.equals(doneDummy)) { diff --git a/src/main/java/forge/control/input/InputPayManaCostUtil.java b/src/main/java/forge/control/input/InputPayManaCostUtil.java index 422adb45420..19d678fc83a 100644 --- a/src/main/java/forge/control/input/InputPayManaCostUtil.java +++ b/src/main/java/forge/control/input/InputPayManaCostUtil.java @@ -33,7 +33,7 @@ import forge.card.mana.ManaCost; import forge.card.mana.ManaPool; import forge.card.spellability.AbilityMana; import forge.card.spellability.SpellAbility; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; /** *

@@ -189,7 +189,7 @@ public class InputPayManaCostUtil { for (final AbilityMana am : abilities) { ability.put(am.toString(), am); } - chosen = GuiUtils.chooseOne("Choose mana ability", abilities); + chosen = GuiChoose.one("Choose mana ability", abilities); } // save off color needed for use by any mana and reflected mana diff --git a/src/main/java/forge/game/limited/BoosterDraft.java b/src/main/java/forge/game/limited/BoosterDraft.java index 641b25f62cd..fa3f9117d06 100644 --- a/src/main/java/forge/game/limited/BoosterDraft.java +++ b/src/main/java/forge/game/limited/BoosterDraft.java @@ -38,7 +38,7 @@ import forge.card.CardBlock; import forge.card.CardEdition; import forge.card.UnOpenedProduct; import forge.deck.Deck; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.item.CardDb; import forge.item.CardPrinted; import forge.item.ItemPool; @@ -110,7 +110,7 @@ public final class BoosterDraft implements IBoosterDraft { } } - final CardBlock block = GuiUtils.chooseOne("Choose Block", blocks); + final CardBlock block = GuiChoose.one("Choose Block", blocks); final CardEdition[] cardSets = block.getSets(); final String[] sets = new String[cardSets.length + block.getNumberMetaSets()]; @@ -135,7 +135,7 @@ public final class BoosterDraft implements IBoosterDraft { } if (sets.length > 1) { - final Object p = GuiUtils.chooseOne("Choose Set Combination", setCombos); + final Object p = GuiChoose.one("Choose Set Combination", setCombos); final String[] pp = p.toString().split("/"); for (int i = 0; i < nPacks; i++) { if (pp[i].charAt(0) == '*') { @@ -168,7 +168,7 @@ public final class BoosterDraft implements IBoosterDraft { JOptionPane .showMessageDialog(null, "No custom draft files found.", "", JOptionPane.INFORMATION_MESSAGE); } else { - final CustomLimited draft = (CustomLimited) GuiUtils.chooseOne("Choose Custom Draft", + final CustomLimited draft = (CustomLimited) GuiChoose.one("Choose Custom Draft", myDrafts); this.setupCustomDraft(draft); } diff --git a/src/main/java/forge/game/limited/SealedDeckFormat.java b/src/main/java/forge/game/limited/SealedDeckFormat.java index 2eb145b5e6e..cb7f6001f46 100644 --- a/src/main/java/forge/game/limited/SealedDeckFormat.java +++ b/src/main/java/forge/game/limited/SealedDeckFormat.java @@ -30,7 +30,7 @@ import forge.card.BoosterGenerator; import forge.card.CardBlock; import forge.card.CardEdition; import forge.card.UnOpenedProduct; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.item.CardDb; import forge.item.CardPrinted; import forge.item.ItemPool; @@ -75,7 +75,7 @@ public class SealedDeckFormat { integers[i] = Integer.valueOf(i + 3); } - Integer nrBoosters = GuiUtils.chooseOne("How many booster packs?", integers); + Integer nrBoosters = GuiChoose.one("How many booster packs?", integers); for (int i = 0; i < nrBoosters; i++) { this.product.add(new UnOpenedProduct(BoosterGenerator.IDENTITY_PICK, bpFull)); @@ -97,7 +97,7 @@ public class SealedDeckFormat { } } - final CardBlock block = GuiUtils.chooseOne("Choose Block", blocks); + final CardBlock block = GuiChoose.one("Choose Block", blocks); final CardEdition[] cardSets = block.getSets(); final String[] sets = new String[cardSets.length + block.getNumberMetaSets()]; @@ -123,7 +123,7 @@ public class SealedDeckFormat { } if (sets.length > 1) { - final Object p = GuiUtils.chooseOne("Choose Set Combination", setCombos); + final Object p = GuiChoose.one("Choose Set Combination", setCombos); final String[] pp = p.toString().split("/"); @@ -179,7 +179,7 @@ public class SealedDeckFormat { starterPacks.add(String.format("Two packs (%s, %s)", pp[starter1idx], pp[starter2idx])); } - final Object starterResult = GuiUtils.chooseOne("Choose starter pack(s):", starterPacks); + final Object starterResult = GuiChoose.one("Choose starter pack(s):", starterPacks); // Analyze the choice final String starters = starterResult.toString(); @@ -229,7 +229,7 @@ public class SealedDeckFormat { integers[i] = Integer.valueOf(i + 3); } - Integer nrBoosters = GuiUtils.chooseOne("How many booster packs?", integers); + Integer nrBoosters = GuiChoose.one("How many booster packs?", integers); for (int i = 0; i < nrBoosters; i++) { this.product.add(product1); @@ -268,7 +268,7 @@ public class SealedDeckFormat { JOptionPane.showMessageDialog(null, "No custom sealed files found.", "", JOptionPane.INFORMATION_MESSAGE); } else { - final CustomLimited draft = (CustomLimited) GuiUtils.chooseOne("Choose Custom Sealed Pool", + final CustomLimited draft = (CustomLimited) GuiChoose.one("Choose Custom Sealed Pool", customs); final BoosterGenerator bpCustom = new BoosterGenerator(draft.getCardPool()); @@ -293,7 +293,7 @@ public class SealedDeckFormat { integers[i] = Integer.valueOf(i + 3); } - Integer nrBoosters = GuiUtils.chooseOne("How many booster packs?", integers); + Integer nrBoosters = GuiChoose.one("How many booster packs?", integers); for (int i = 0; i < nrBoosters; i++) { this.product.add(new UnOpenedProduct(fnPick, bpCustom)); diff --git a/src/main/java/forge/game/phase/CombatUtil.java b/src/main/java/forge/game/phase/CombatUtil.java index f6245ff6c3b..c856bde1463 100644 --- a/src/main/java/forge/game/phase/CombatUtil.java +++ b/src/main/java/forge/game/phase/CombatUtil.java @@ -60,7 +60,7 @@ import forge.game.player.ComputerUtilBlock; import forge.game.player.Player; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.framework.EDocID; import forge.gui.framework.SDisplayUtil; import forge.gui.match.views.VCombat; @@ -443,7 +443,7 @@ public class CombatUtil { CardList orderedBlockers = null; if (player.isHuman()) { - List ordered = GuiUtils.getOrderChoices("Choose Blocking Order", "Damaged First", 0, blockers.toArray(), null); + List ordered = GuiChoose.getOrderChoices("Choose Blocking Order", "Damaged First", 0, blockers.toArray(), null); orderedBlockers = new CardList(); for(Object o : ordered) { @@ -471,7 +471,7 @@ public class CombatUtil { CardList orderedAttacker = null; if (player.isHuman()) { - List ordered = GuiUtils.getOrderChoices("Choose Blocking Order", "Damaged First", 0, attackers.toArray(), null); + List ordered = GuiChoose.getOrderChoices("Choose Blocking Order", "Damaged First", 0, attackers.toArray(), null); orderedAttacker = new CardList(); for(Object o : ordered) { @@ -2836,7 +2836,7 @@ public class CombatUtil { if (lib.size() > 0) { final CardList cl = new CardList(); cl.add(lib.get(0)); - GuiUtils.chooseOneOrNone("Top card", cl); + GuiChoose.oneOrNone("Top card", cl); final Card top = lib.get(0); if (top.isCreature()) { player.gainLife(top.getBaseDefense(), c); @@ -3103,7 +3103,7 @@ public class CombatUtil { final Card crd = enchantments.get(j); target[j] = crd; } - final Object check = GuiUtils.chooseOneOrNone( + final Object check = GuiChoose.oneOrNone( "Select enchantment to enchant exalted creature", target); if (check != null) { enchantment = ((Card) check); diff --git a/src/main/java/forge/game/phase/Upkeep.java b/src/main/java/forge/game/phase/Upkeep.java index 1963e8812da..8789e1af635 100644 --- a/src/main/java/forge/game/phase/Upkeep.java +++ b/src/main/java/forge/game/phase/Upkeep.java @@ -46,7 +46,7 @@ import forge.game.player.Player; import forge.game.player.PlayerUtil; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.match.CMatchUI; import forge.view.ButtonUtil; @@ -778,7 +778,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private void revealTopCard(final String title) { if (peek[0] != prevCardShown[0]) { - GuiUtils.chooseOne(title, peek[0]); + GuiChoose.one(title, peek[0]); prevCardShown[0] = peek[0]; } } // revealTopCard() @@ -880,7 +880,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private void revealTopCard(final String title) { if (peek[0] != prevCardShown[0]) { - GuiUtils.chooseOne(title, peek[0]); + GuiChoose.one(title, peek[0]); prevCardShown[0] = peek[0]; } } // revealTopCard() @@ -980,7 +980,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private void revealTopCard(final String title) { if (peek[0] != prevCardShown[0]) { - GuiUtils.chooseOne(title, peek[0]); + GuiChoose.one(title, peek[0]); prevCardShown[0] = peek[0]; } } // revealTopCard() @@ -1077,7 +1077,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private void revealTopCard(final String title) { if (peek[0] != prevCardShown[0]) { - GuiUtils.chooseOne(title, peek[0]); + GuiChoose.one(title, peek[0]); prevCardShown[0] = peek[0]; } } // revealTopCard() @@ -1162,7 +1162,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private void revealTopCard(final String title) { if (peek[0] != prevCardShown[0]) { - GuiUtils.chooseOne(title, peek[0]); + GuiChoose.one(title, peek[0]); prevCardShown[0] = peek[0]; } } // revealTopCard() @@ -1261,7 +1261,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private void revealTopCard(final String title) { if (peek[0] != prevCardShown[0]) { - GuiUtils.chooseOne(title, peek[0]); + GuiChoose.one(title, peek[0]); prevCardShown[0] = peek[0]; } } // revealTopCard() @@ -1353,7 +1353,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private void revealTopCard(final String title) { if (peek[0] != prevCardShown[0]) { - GuiUtils.chooseOne(title, peek[0]); + GuiChoose.one(title, peek[0]); prevCardShown[0] = peek[0]; } } // revealTopCard() @@ -1439,7 +1439,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private void revealTopCard(final String title) { if (peek[0] != prevCardShown[0]) { - GuiUtils.chooseOne(title, peek[0]); + GuiChoose.one(title, peek[0]); prevCardShown[0] = peek[0]; } } // revealTopCard() @@ -1523,7 +1523,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private void revealTopCard(final String title) { if (peek[0] != prevCardShown[0]) { - GuiUtils.chooseOne(title, peek[0]); + GuiChoose.one(title, peek[0]); prevCardShown[0] = peek[0]; } } // revealTopCard() @@ -1628,7 +1628,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private void revealTopCard(final String title) { if (peek[0] != prevCardShown[0]) { - GuiUtils.chooseOne(title, peek[0]); + GuiChoose.one(title, peek[0]); prevCardShown[0] = peek[0]; } } // revealTopCard() @@ -1712,7 +1712,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private void revealTopCard(final String title) { if (peek[0] != prevCardShown[0]) { - GuiUtils.chooseOne(title, peek[0]); + GuiChoose.one(title, peek[0]); prevCardShown[0] = peek[0]; } } // revealTopCard() @@ -1799,7 +1799,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private void revealTopCard(final String title) { if (peek[0] != prevCardShown[0]) { - GuiUtils.chooseOne(title, peek[0]); + GuiChoose.one(title, peek[0]); prevCardShown[0] = peek[0]; } } // revealTopCard() @@ -1986,7 +1986,7 @@ public class Upkeep extends Phase implements java.io.Serializable { } } // for loop if (cardsToReveal.size() > 0) { - GuiUtils.chooseOne("Revealed cards", cardsToReveal); + GuiChoose.one("Revealed cards", cardsToReveal); } } } @@ -2030,7 +2030,7 @@ public class Upkeep extends Phase implements java.io.Serializable { if (AllZoneUtil.compareTypeAmountInGraveyard(player, "Creature") > 0) { if (player.isHuman()) { - final Card o = GuiUtils.chooseOneOrNone("Pick a creature to return to hand", graveyardCreatures); + final Card o = GuiChoose.oneOrNone("Pick a creature to return to hand", graveyardCreatures); if (o != null) { final Card card = (Card) o; @@ -2292,7 +2292,7 @@ public class Upkeep extends Phase implements java.io.Serializable { final Card crd = enchantmentsInLibrary.get(j); target[j] = crd; } - final Object check = GuiUtils.chooseOneOrNone("Select Curse to attach", target); + final Object check = GuiChoose.oneOrNone("Select Curse to attach", target); if (check != null) { enchantment = ((Card) check); } diff --git a/src/main/java/forge/game/player/ComputerUtil.java b/src/main/java/forge/game/player/ComputerUtil.java index d46a447025e..06f857afbc5 100644 --- a/src/main/java/forge/game/player/ComputerUtil.java +++ b/src/main/java/forge/game/player/ComputerUtil.java @@ -59,7 +59,7 @@ import forge.game.phase.Combat; import forge.game.phase.CombatUtil; import forge.game.phase.PhaseType; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.util.Aggregates; @@ -182,7 +182,7 @@ public class ComputerUtil { if (pay.payComputerCosts()) { AllZone.getStack().addAndUnfreeze(sa); if (sa.getSplicedCards() != null && !sa.getSplicedCards().isEmpty()) { - GuiUtils.chooseOneOrNone("Computer reveals spliced cards:", sa.getSplicedCards()); + GuiChoose.oneOrNone("Computer reveals spliced cards:", sa.getSplicedCards()); } return true; // TODO: solve problems with TapsForMana triggers by adding diff --git a/src/main/java/forge/game/player/HumanPlayer.java b/src/main/java/forge/game/player/HumanPlayer.java index e4d80935d95..a2b4195f61d 100644 --- a/src/main/java/forge/game/player/HumanPlayer.java +++ b/src/main/java/forge/game/player/HumanPlayer.java @@ -24,7 +24,7 @@ import forge.Singletons; import forge.card.spellability.SpellAbility; import forge.control.input.Input; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.match.CMatchUI; /** @@ -124,9 +124,9 @@ public class HumanPlayer extends Player { public final boolean dredge() { boolean dredged = false; final String[] choices = { "Yes", "No" }; - final Object o = GuiUtils.chooseOne("Do you want to dredge?", choices); + final Object o = GuiChoose.one("Do you want to dredge?", choices); if (o.equals("Yes")) { - final Card c = GuiUtils.chooseOne("Select card to dredge", this.getDredge()); + final Card c = GuiChoose.one("Select card to dredge", this.getDredge()); // rule 702.49a if (this.getDredgeNumber(c) <= AllZone.getHumanPlayer().getZone(ZoneType.Library).size()) { @@ -181,7 +181,7 @@ public class HumanPlayer extends Player { protected final void doScry(final CardList topN, final int n) { int num = n; for (int i = 0; i < num; i++) { - final Card c = GuiUtils.chooseOneOrNone("Put on bottom of library.", topN); + final Card c = GuiChoose.oneOrNone("Put on bottom of library.", topN); if (c != null) { topN.remove(c); Singletons.getModel().getGameAction().moveToBottomOfLibrary(c); @@ -192,7 +192,7 @@ public class HumanPlayer extends Player { } num = topN.size(); for (int i = 0; i < num; i++) { - final Card c = GuiUtils.chooseOne("Put on top of library.", topN); + final Card c = GuiChoose.one("Put on top of library.", topN); if (c != null) { topN.remove(c); Singletons.getModel().getGameAction().moveToLibrary(c); @@ -214,7 +214,7 @@ public class HumanPlayer extends Player { String choice = ""; final String[] choices = { "top", "bottom" }; CMatchUI.SINGLETON_INSTANCE.setCard(c); - choice = GuiUtils.chooseOne(c.getName() + " - Top or bottom of Library", choices); + choice = GuiChoose.one(c.getName() + " - Top or bottom of Library", choices); if (choice.equals("bottom")) { Singletons.getModel().getGameAction().moveToBottomOfLibrary(c); diff --git a/src/main/java/forge/game/player/Player.java b/src/main/java/forge/game/player/Player.java index 43d630d8676..80248539a24 100644 --- a/src/main/java/forge/game/player/Player.java +++ b/src/main/java/forge/game/player/Player.java @@ -52,7 +52,7 @@ import forge.game.zone.DefaultPlayerZone; import forge.game.zone.PlayerZone; import forge.game.zone.PlayerZoneComesIntoPlay; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.properties.ForgePreferences.FPref; import forge.util.MyRandom; @@ -1280,7 +1280,7 @@ public abstract class Player extends GameEntity implements Comparable { } } if (reveal) { - GuiUtils.chooseOne("Revealing the first card drawn", drawn); + GuiChoose.one("Revealing the first card drawn", drawn); } } diff --git a/src/main/java/forge/game/zone/MagicStack.java b/src/main/java/forge/game/zone/MagicStack.java index 7dbb73627de..4c2bc9ed3e0 100644 --- a/src/main/java/forge/game/zone/MagicStack.java +++ b/src/main/java/forge/game/zone/MagicStack.java @@ -51,7 +51,7 @@ import forge.control.input.InputPayManaCostAbility; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.framework.EDocID; import forge.gui.framework.SDisplayUtil; import forge.gui.match.CMatchUI; @@ -1350,7 +1350,7 @@ public class MagicStack extends MyObservable { } else{ // Otherwise, gave a dual list form to create instead of needing to do it one at a time - List orderedSAs = GuiUtils.getOrderChoices("Select order for Simultaneous Spell Abilities", "Resolve first", 0, activePlayerSAs.toArray(), null); + List orderedSAs = GuiChoose.getOrderChoices("Select order for Simultaneous Spell Abilities", "Resolve first", 0, activePlayerSAs.toArray(), null); int size = orderedSAs.size(); for(int i = size-1; i >= 0; i--){ SpellAbility next = (SpellAbility)orderedSAs.get(i); diff --git a/src/main/java/forge/gui/GuiChoose.java b/src/main/java/forge/gui/GuiChoose.java new file mode 100644 index 00000000000..1b508b5e879 --- /dev/null +++ b/src/main/java/forge/gui/GuiChoose.java @@ -0,0 +1,196 @@ +package forge.gui; + +import java.awt.BorderLayout; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JList; +import javax.swing.WindowConstants; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +import forge.Card; +import forge.gui.match.CMatchUI; + +/** + * TODO: Write javadoc for this type. + * + */ +public class GuiChoose { + + /** + * Convenience for getChoices(message, 0, 1, choices). + * + * @param + * is automatically inferred. + * @param message + * a {@link java.lang.String} object. + * @param choices + * a T object. + * @return null if choices is missing, empty, or if the users' choices are + * empty; otherwise, returns the first item in the List returned by + * getChoices. + * @see #getChoices(String, int, int, Object...) + */ + public static T oneOrNone(final String message, final T[] choices) { + if ((choices == null) || (choices.length == 0)) { + return null; + } + final List choice = GuiChoose.getChoices(message, 0, 1, choices); + return choice.isEmpty() ? null : choice.get(0); + } // getChoiceOptional(String,T...) + + public static T oneOrNone(final String message, final Collection choices) { + if ((choices == null) || (choices.size() == 0)) { + return null; + } + final List choice = GuiChoose.getChoices(message, 0, 1, choices); + return choice.isEmpty() ? null : choice.get(0); + } // getChoiceOptional(String,T...) + + // returned Object will never be null + /** + *

+ * getChoice. + *

+ * + * @param + * a T object. + * @param message + * a {@link java.lang.String} object. + * @param choices + * a T object. + * @return a T object. + */ + public static T one(final String message, final T[] choices) { + final List choice = GuiChoose.getChoices(message, 1, 1, choices); + assert choice.size() == 1; + return choice.get(0); + } // getChoice() + + // Nothing to choose here. Code uses this to just show a card. + public static Card one(final String message, final Card singleChoice) { + List choices = new ArrayList(); + choices.add(singleChoice); + return one(message, choices); + } + + public static T one(final String message, final Collection choices) { + final List choice = GuiChoose.getChoices(message, 1, 1, choices); + assert choice.size() == 1; + return choice.get(0); + } + + // returned Object will never be null + /** + *

+ * getChoicesOptional. + *

+ * + * @param + * a T object. + * @param message + * a {@link java.lang.String} object. + * @param choices + * a T object. + * @return a {@link java.util.List} object. + */ + public static List noneOrMany(final String message, final T[] choices) { + return GuiChoose.getChoices(message, 0, choices.length, choices); + } // getChoice() + + public static List noneOrMany(final String message, final List choices) { + return GuiChoose.getChoices(message, 0, choices.size(), choices); + } + + // returned Object will never be null + /** + *

+ * getChoices. + *

+ * + * @param + * a T object. + * @param message + * a {@link java.lang.String} object. + * @param choices + * a T object. + * @return a {@link java.util.List} object. + */ + public static List oneOrMany(final String message, final T[] choices) { + return GuiChoose.getChoices(message, 1, choices.length, choices); + } // getChoice() + + // returned Object will never be null + /** + *

+ * getChoices. + *

+ * + * @param + * a T object. + * @param message + * a {@link java.lang.String} object. + * @param min + * a int. + * @param max + * a int. + * @param choices + * a T object. + * @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); + return getChoices(c); + } + + private static List getChoices(final String message, final int min, final int max, final Collection choices) { + final ListChooser c = new ListChooser(message, min, max, choices); + return getChoices(c); + } + + private static List getChoices(final ListChooser c) { + + final JList list = c.getJList(); + list.addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(final ListSelectionEvent ev) { + if (list.getSelectedValue() instanceof Card) { + CMatchUI.SINGLETON_INSTANCE.setCard((Card) list.getSelectedValue()); + } + } + }); + c.show(); + return c.getSelectedValues(); + } // getChoice() + + public static List getOrderChoices(final String title, final String top, int remainingObjects, final Object[] sourceChoices, Object[] destChoices) { + // An input box for handling the order of choices. + final JFrame frame = new JFrame(); + DualListBox dual = new DualListBox(remainingObjects, top, sourceChoices, destChoices); + + frame.setLayout(new BorderLayout()); + frame.setSize(dual.getPreferredSize()); + frame.add(dual); + frame.setTitle(title); + frame.setVisible(false); + + final JDialog dialog = new JDialog(frame, true); + dialog.setTitle(title); + dialog.setContentPane(dual); + dialog.setSize(dual.getPreferredSize()); + dialog.setLocationRelativeTo(null); + dialog.pack(); + dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + dialog.setVisible(true); + + List objects = dual.getOrderedList(); + + dialog.dispose(); + return objects; + } + +} diff --git a/src/main/java/forge/gui/GuiDisplayUtil.java b/src/main/java/forge/gui/GuiDisplayUtil.java index 67f3199b457..c2c8a250e4d 100644 --- a/src/main/java/forge/gui/GuiDisplayUtil.java +++ b/src/main/java/forge/gui/GuiDisplayUtil.java @@ -620,7 +620,7 @@ public final class GuiDisplayUtil { */ public static void devModeTutor() { final CardList lib = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); - final Object o = GuiUtils.chooseOneOrNone("Choose a card", lib); + final Object o = GuiChoose.oneOrNone("Choose a card", lib); if (null == o) { return; } else { @@ -685,12 +685,12 @@ public final class GuiDisplayUtil { * @since 1.0.15 */ public static void devModeAddCounter() { - final Card o = GuiUtils.chooseOneOrNone("Add counters to which card?", AllZoneUtil.getCardsIn(ZoneType.Battlefield)); + final Card o = GuiChoose.oneOrNone("Add counters to which card?", AllZoneUtil.getCardsIn(ZoneType.Battlefield)); if (null == o) { return; } else { final Card c = (Card) o; - final Counters counter = GuiUtils.chooseOneOrNone("Which type of counter?", Counters.values()); + final Counters counter = GuiChoose.oneOrNone("Which type of counter?", Counters.values()); if (null == counter) { return; } else { @@ -698,7 +698,7 @@ public final class GuiDisplayUtil { for (int j = 0; j < 99; j++) { integers[j] = Integer.valueOf(j); } - final Integer i = GuiUtils.chooseOneOrNone("How many counters?", integers); + final Integer i = GuiChoose.oneOrNone("How many counters?", integers); if (null == i) { return; } else { @@ -717,7 +717,7 @@ public final class GuiDisplayUtil { */ public static void devModeTapPerm() { final CardList play = AllZoneUtil.getCardsIn(ZoneType.Battlefield); - final Object o = GuiUtils.chooseOneOrNone("Choose a permanent", play); + final Object o = GuiChoose.oneOrNone("Choose a permanent", play); if (null == o) { return; } else { @@ -735,7 +735,7 @@ public final class GuiDisplayUtil { */ public static void devModeUntapPerm() { final CardList play = AllZoneUtil.getCardsIn(ZoneType.Battlefield); - final Object o = GuiUtils.chooseOneOrNone("Choose a permanent", play); + final Object o = GuiChoose.oneOrNone("Choose a permanent", play); if (null == o) { return; } else { @@ -764,7 +764,7 @@ public final class GuiDisplayUtil { */ public static void devModeSetLife() { final List players = AllZone.getPlayersInGame(); - final Player o = GuiUtils.chooseOneOrNone("Set life for which player?", players); + final Player o = GuiChoose.oneOrNone("Set life for which player?", players); if (null == o) { return; } else { @@ -773,7 +773,7 @@ public final class GuiDisplayUtil { for (int j = 0; j < 99; j++) { integers[j] = Integer.valueOf(j); } - final Integer i = GuiUtils.chooseOneOrNone("Set life to what?", integers); + final Integer i = GuiChoose.oneOrNone("Set life to what?", integers); if (null == i) { return; } else { diff --git a/src/main/java/forge/gui/GuiUtils.java b/src/main/java/forge/gui/GuiUtils.java index e94e4e921c1..b5562a6bc5b 100644 --- a/src/main/java/forge/gui/GuiUtils.java +++ b/src/main/java/forge/gui/GuiUtils.java @@ -17,36 +17,19 @@ */ package forge.gui; -import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.Font; import java.awt.FontFormatException; -import java.awt.Image; import java.awt.Rectangle; import java.awt.Window; -import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; import javax.swing.Box; -import javax.swing.ImageIcon; -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JList; import javax.swing.JPanel; import javax.swing.SwingUtilities; -import javax.swing.WindowConstants; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import forge.Card; -import forge.gui.match.CMatchUI; -import forge.properties.ForgeProps; -import forge.properties.NewConstants; /** *

@@ -140,264 +123,6 @@ public final class GuiUtils { component.setFont(oldFont.deriveFont((float) newSize)); } - /** - *

- * getIconFromFile. - *

- * - * @param filename - * a {@link java.lang.String} object. - * @return a {@link javax.swing.ImageIcon} object. - */ - public static ImageIcon getIconFromFile(final String filename) { - final File base = ForgeProps.getFile(NewConstants.IMAGE_ICON); - final File file = new File(base, filename); - if (filename.equals("") || !file.exists()) { - return null; - } else { - return new ImageIcon(file.toString()); - } - } - - /** - *

- * getResizedIcon. - *

- * - * @param filename - * String. - * @param scale - * Double. - * @return {@link javax.swing.ImageIcon} object - */ - public static ImageIcon getResizedIcon(final String filename, final double scale) { - final ImageIcon icon = GuiUtils.getIconFromFile(filename); - - final int w = (int) (icon.getIconWidth() * scale); - final int h = (int) (icon.getIconHeight() * scale); - - return new ImageIcon(icon.getImage().getScaledInstance(w, h, Image.SCALE_SMOOTH)); - } - - /** - *

- * getResizedIcon. - *

- * - * @param icon - * ImageIcon - * @param scale - * Double - * @return {@link javax.swing.ImageIcon} object - */ - public static ImageIcon getResizedIcon(final ImageIcon icon, final double scale) { - final int w = (int) (icon.getIconWidth() * scale); - final int h = (int) (icon.getIconHeight() * scale); - - return new ImageIcon(icon.getImage().getScaledInstance(w, h, Image.SCALE_SMOOTH)); - } - - /** - *

- * getResizedIcon. - *

- * - * @param icon - * a {@link javax.swing.ImageIcon} object. - * @param width - * a int. - * @param height - * a int. - * @return a {@link javax.swing.ImageIcon} object. - */ - public static ImageIcon getResizedIcon(final ImageIcon icon, final int width, final int height) { - return new ImageIcon(icon.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH)); - } - - /** - *

- * getEmptyIcon. - *

- * - * @param width - * a int. - * @param height - * a int. - * @return a {@link javax.swing.ImageIcon} object. - */ - public static ImageIcon getEmptyIcon(final int width, final int height) { - return new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB)); - } - - /** - * Convenience for getChoices(message, 0, 1, choices). - * - * @param - * is automatically inferred. - * @param message - * a {@link java.lang.String} object. - * @param choices - * a T object. - * @return null if choices is missing, empty, or if the users' choices are - * empty; otherwise, returns the first item in the List returned by - * getChoices. - * @see #getChoices(String, int, int, Object...) - */ - public static T chooseOneOrNone(final String message, final T[] choices) { - if ((choices == null) || (choices.length == 0)) { - return null; - } - final List choice = GuiUtils.getChoices(message, 0, 1, choices); - return choice.isEmpty() ? null : choice.get(0); - } // getChoiceOptional(String,T...) - - public static T chooseOneOrNone(final String message, final Collection choices) { - if ((choices == null) || (choices.size() == 0)) { - return null; - } - final List choice = GuiUtils.getChoices(message, 0, 1, choices); - return choice.isEmpty() ? null : choice.get(0); - } // getChoiceOptional(String,T...) - - // returned Object will never be null - /** - *

- * getChoice. - *

- * - * @param - * a T object. - * @param message - * a {@link java.lang.String} object. - * @param choices - * a T object. - * @return a T object. - */ - public static T chooseOne(final String message, final T[] choices) { - final List choice = GuiUtils.getChoices(message, 1, 1, choices); - assert choice.size() == 1; - return choice.get(0); - } // getChoice() - - // Nothing to choose here. Code uses this to just show a card. - public static Card chooseOne(final String message, final Card singleChoice) { - List choices = new ArrayList(); - choices.add(singleChoice); - return chooseOne(message, choices); - } - - public static T chooseOne(final String message, final Collection choices) { - final List choice = GuiUtils.getChoices(message, 1, 1, choices); - assert choice.size() == 1; - return choice.get(0); - } - - // returned Object will never be null - /** - *

- * getChoicesOptional. - *

- * - * @param - * a T object. - * @param message - * a {@link java.lang.String} object. - * @param choices - * a T object. - * @return a {@link java.util.List} object. - */ - public static List chooseNoneOrMany(final String message, final T[] choices) { - return GuiUtils.getChoices(message, 0, choices.length, choices); - } // getChoice() - public static List chooseNoneOrMany(final String message, final List choices) { - return GuiUtils.getChoices(message, 0, choices.size(), choices); - } - // returned Object will never be null - /** - *

- * getChoices. - *

- * - * @param - * a T object. - * @param message - * a {@link java.lang.String} object. - * @param choices - * a T object. - * @return a {@link java.util.List} object. - */ - public static List chooseOneOrMany(final String message, final T[] choices) { - return GuiUtils.getChoices(message, 1, choices.length, choices); - } // getChoice() - - // returned Object will never be null - /** - *

- * getChoices. - *

- * - * @param - * a T object. - * @param message - * a {@link java.lang.String} object. - * @param min - * a int. - * @param max - * a int. - * @param choices - * a T object. - * @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); - return getChoices(c); - } - - private static List getChoices(final String message, final int min, final int max, final Collection choices) { - final ListChooser c = new ListChooser(message, min, max, choices); - return getChoices(c); - } - - private static List getChoices(final ListChooser c) { - - final JList list = c.getJList(); - list.addListSelectionListener(new ListSelectionListener() { - @Override - public void valueChanged(final ListSelectionEvent ev) { - if (list.getSelectedValue() instanceof Card) { - CMatchUI.SINGLETON_INSTANCE.setCard((Card) list.getSelectedValue()); - } - } - }); - c.show(); - return c.getSelectedValues(); - } // getChoice() - - public static List getOrderChoices(final String title, final String top, int remainingObjects, final Object[] sourceChoices, Object[] destChoices) { - // An input box for handling the order of choices. - final JFrame frame = new JFrame(); - DualListBox dual = new DualListBox(remainingObjects, top, sourceChoices, destChoices); - - frame.setLayout(new BorderLayout()); - frame.setSize(dual.getPreferredSize()); - frame.add(dual); - frame.setTitle(title); - frame.setVisible(false); - - final JDialog dialog = new JDialog(frame, true); - dialog.setTitle(title); - dialog.setContentPane(dual); - dialog.setSize(dual.getPreferredSize()); - dialog.setLocationRelativeTo(null); - dialog.pack(); - dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); - dialog.setVisible(true); - - List objects = dual.getOrderedList(); - - dialog.dispose(); - return objects; - } /** * Centers a frame on the screen based on its current size. @@ -437,26 +162,6 @@ public final class GuiUtils { return ttf; } - /** Duplicate in DeckEditorQuestMenu and - * probably elsewhere...can streamline at some point - * (probably shouldn't be here). - * - * @param in   {@link java.lang.String} - * @return {@link java.lang.String} - */ - public static String cleanString(final String in) { - final StringBuffer out = new StringBuffer(); - final char[] c = in.toCharArray(); - - for (int i = 0; (i < c.length) && (i < 20); i++) { - if (Character.isLetterOrDigit(c[i]) || (c[i] == '-') || (c[i] == '_') || (c[i] == ' ')) { - out.append(c[i]); - } - } - - return out.toString(); - } - /** Checks if calling method uses event dispatch thread. * Exception thrown if method is on "wrong" thread. * A boolean is passed to indicate if the method must be EDT or not. diff --git a/src/main/java/forge/gui/home/quest/CSubmenuQuestData.java b/src/main/java/forge/gui/home/quest/CSubmenuQuestData.java index 53a04163d14..bc0fcba1e8f 100644 --- a/src/main/java/forge/gui/home/quest/CSubmenuQuestData.java +++ b/src/main/java/forge/gui/home/quest/CSubmenuQuestData.java @@ -15,7 +15,6 @@ import javax.swing.JOptionPane; import forge.AllZone; import forge.Command; import forge.Singletons; -import forge.gui.GuiUtils; import forge.gui.framework.ICDoc; import forge.properties.ForgeProps; import forge.properties.NewConstants; @@ -151,7 +150,7 @@ public enum CSubmenuQuestData implements ICDoc { if (o == null) { return; } - final String questName = GuiUtils.cleanString(o.toString()); + final String questName = SSubmenuQuestUtil.cleanString(o.toString()); if (getAllQuests().get(questName) != null || questName.equals("")) { JOptionPane.showMessageDialog(null, "Please pick another quest name, a quest already has that name."); diff --git a/src/main/java/forge/gui/home/quest/QuestFileLister.java b/src/main/java/forge/gui/home/quest/QuestFileLister.java index 13069509594..3153d9cc6c2 100644 --- a/src/main/java/forge/gui/home/quest/QuestFileLister.java +++ b/src/main/java/forge/gui/home/quest/QuestFileLister.java @@ -18,7 +18,6 @@ import javax.swing.border.MatteBorder; import net.miginfocom.swing.MigLayout; import forge.Command; -import forge.gui.GuiUtils; import forge.gui.toolbox.FLabel; import forge.gui.toolbox.FSkin; import forge.properties.ForgeProps; @@ -300,7 +299,7 @@ public class QuestFileLister extends JPanel { if (o == null) { return; } - final String questName = GuiUtils.cleanString(o.toString()); + final String questName = SSubmenuQuestUtil.cleanString(o.toString()); boolean exists = false; diff --git a/src/main/java/forge/gui/home/quest/SSubmenuQuestUtil.java b/src/main/java/forge/gui/home/quest/SSubmenuQuestUtil.java index 2db5ccf9b75..0c16bba3129 100644 --- a/src/main/java/forge/gui/home/quest/SSubmenuQuestUtil.java +++ b/src/main/java/forge/gui/home/quest/SSubmenuQuestUtil.java @@ -349,5 +349,25 @@ public class SSubmenuQuestUtil { return event; } } + + /** Duplicate in DeckEditorQuestMenu and + * probably elsewhere...can streamline at some point + * (probably shouldn't be here). + * + * @param in   {@link java.lang.String} + * @return {@link java.lang.String} + */ + public static String cleanString(final String in) { + final StringBuffer out = new StringBuffer(); + final char[] c = in.toCharArray(); + + for (int i = 0; (i < c.length) && (i < 20); i++) { + if (Character.isLetterOrDigit(c[i]) || (c[i] == '-') || (c[i] == '_') || (c[i] == ' ')) { + out.append(c[i]); + } + } + + return out.toString(); + } } diff --git a/src/main/java/forge/gui/home/sanctioned/CSubmenuDraft.java b/src/main/java/forge/gui/home/sanctioned/CSubmenuDraft.java index 3e2d748c33c..bdc60575ce9 100644 --- a/src/main/java/forge/gui/home/sanctioned/CSubmenuDraft.java +++ b/src/main/java/forge/gui/home/sanctioned/CSubmenuDraft.java @@ -21,7 +21,7 @@ import forge.game.GameNew; import forge.game.GameType; import forge.game.limited.BoosterDraft; import forge.game.limited.CardPoolLimitation; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.SOverlayUtils; import forge.gui.deckeditor.CDeckEditorUI; import forge.gui.deckeditor.controllers.CEditorDraftingProcess; @@ -234,7 +234,7 @@ public enum CSubmenuDraft implements ICDoc { draftTypes.add("Custom"); final String prompt = "Choose Draft Format:"; - final Object o = GuiUtils.chooseOne(prompt, draftTypes); + final Object o = GuiChoose.one(prompt, draftTypes); if (o.toString().equals(draftTypes.get(0))) { draft.showGui(new BoosterDraft(CardPoolLimitation.Full)); diff --git a/src/main/java/forge/gui/home/sanctioned/CSubmenuSealed.java b/src/main/java/forge/gui/home/sanctioned/CSubmenuSealed.java index 58bb82db76f..22b4080496c 100644 --- a/src/main/java/forge/gui/home/sanctioned/CSubmenuSealed.java +++ b/src/main/java/forge/gui/home/sanctioned/CSubmenuSealed.java @@ -23,7 +23,7 @@ import forge.deck.DeckGroup; import forge.game.GameType; import forge.game.limited.SealedDeck; import forge.game.limited.SealedDeckFormat; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.deckeditor.CDeckEditorUI; import forge.gui.deckeditor.controllers.ACEditorBase; import forge.gui.deckeditor.controllers.CEditorLimited; @@ -140,7 +140,7 @@ public enum CSubmenuSealed implements ICDoc { sealedTypes.add("Custom"); final String prompt = "Choose Sealed Deck Format:"; - final Object o = GuiUtils.chooseOne(prompt, sealedTypes); + final Object o = GuiChoose.one(prompt, sealedTypes); SealedDeckFormat sd = null; @@ -177,7 +177,7 @@ public enum CSubmenuSealed implements ICDoc { integers[i] = Integer.valueOf(i + 1); } - Integer rounds = GuiUtils.chooseOne("How many rounds?", integers); + Integer rounds = GuiChoose.one("How many rounds?", integers); // System.out.println("You selected " + rounds + " rounds."); diff --git a/src/main/java/forge/gui/match/ControlWinLose.java b/src/main/java/forge/gui/match/ControlWinLose.java index 0fc7fb31570..bd16bc65680 100644 --- a/src/main/java/forge/gui/match/ControlWinLose.java +++ b/src/main/java/forge/gui/match/ControlWinLose.java @@ -16,7 +16,7 @@ import forge.deck.Deck; import forge.game.GameNew; import forge.game.GameType; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; +import forge.gui.GuiChoose; import forge.gui.SOverlayUtils; import forge.item.CardDb; import forge.item.CardPrinted; @@ -106,7 +106,7 @@ public class ControlWinLose { Constant.Runtime.COMPUTER_DECK[0] = cDeck; - List o = GuiUtils.chooseNoneOrMany("Select cards to add to your deck", compAntes); + List o = GuiChoose.noneOrMany("Select cards to add to your deck", compAntes); if (null != o) { for (Card c : o) { hDeck.getMain().add(c); diff --git a/src/main/java/forge/gui/match/QuestWinLoseHandler.java b/src/main/java/forge/gui/match/QuestWinLoseHandler.java index 8cfff49f2c1..5db3d4e9a66 100644 --- a/src/main/java/forge/gui/match/QuestWinLoseHandler.java +++ b/src/main/java/forge/gui/match/QuestWinLoseHandler.java @@ -30,7 +30,6 @@ import forge.game.GamePlayerRating; import forge.game.GameSummary; import forge.game.player.Player; import forge.game.zone.ZoneType; -import forge.gui.GuiUtils; import forge.gui.ListChooser; import forge.gui.SOverlayUtils; import forge.gui.home.quest.CSubmenuChallenges; @@ -51,6 +50,7 @@ import forge.util.MyRandom; import java.awt.Color; import java.awt.Dimension; +import java.awt.Image; import java.util.ArrayList; import java.util.List; @@ -486,7 +486,7 @@ public class QuestWinLoseHandler extends ControlWinLose { qData.getAssets().addCredits(credTotal); // Generate Swing components and attach. - this.icoTemp = GuiUtils.getResizedIcon(FSkin.getIcon(FSkin.QuestIcons.ICO_GOLD), 0.5); + this.icoTemp = QuestWinLoseHandler.getResizedIcon(FSkin.getIcon(FSkin.QuestIcons.ICO_GOLD), 0.5); this.lblTemp1 = new TitleLabel("Gameplay Results"); @@ -594,7 +594,7 @@ public class QuestWinLoseHandler extends ControlWinLose { qData.getAssets().addCredits(questRewardCredits); // Generate Swing components and attach. - this.icoTemp = GuiUtils.getResizedIcon(FSkin.getIcon(FSkin.QuestIcons.ICO_BOX), 0.5); + this.icoTemp = QuestWinLoseHandler.getResizedIcon(FSkin.getIcon(FSkin.QuestIcons.ICO_BOX), 0.5); this.lblTemp1 = new TitleLabel("Challenge Rewards for \"" + ((QuestEventChallenge) qEvent).getTitle() + "\""); this.lblTemp2 = new JLabel(sb.toString()); @@ -616,7 +616,7 @@ public class QuestWinLoseHandler extends ControlWinLose { private void penalizeLoss() { final int x = Singletons.getModel().getQuestPreferences().getPreferenceInt(QPref.PENALTY_LOSS); - this.icoTemp = GuiUtils.getResizedIcon(FSkin.getIcon(FSkin.QuestIcons.ICO_HEART), 0.5); + this.icoTemp = QuestWinLoseHandler.getResizedIcon(FSkin.getIcon(FSkin.QuestIcons.ICO_HEART), 0.5); this.lblTemp1 = new TitleLabel("Gameplay Results"); @@ -699,6 +699,24 @@ public class QuestWinLoseHandler extends ControlWinLose { return credits; } + /** + *

+ * getResizedIcon. + *

+ * + * @param icon + * ImageIcon + * @param scale + * Double + * @return {@link javax.swing.ImageIcon} object + */ + public static ImageIcon getResizedIcon(final ImageIcon icon, final double scale) { + final int w = (int) (icon.getIconWidth() * scale); + final int h = (int) (icon.getIconHeight() * scale); + + return new ImageIcon(icon.getImage().getScaledInstance(w, h, Image.SCALE_SMOOTH)); + } + /** * JLabel header between reward sections. * diff --git a/src/main/java/forge/gui/match/nonsingleton/CField.java b/src/main/java/forge/gui/match/nonsingleton/CField.java index d44db0a3046..0f9c32372ee 100644 --- a/src/main/java/forge/gui/match/nonsingleton/CField.java +++ b/src/main/java/forge/gui/match/nonsingleton/CField.java @@ -49,8 +49,8 @@ import forge.game.player.Player; import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; import forge.gui.ForgeAction; +import forge.gui.GuiChoose; import forge.gui.GuiDisplayUtil; -import forge.gui.GuiUtils; import forge.gui.framework.ICDoc; import forge.gui.match.CMatchUI; import forge.gui.match.controllers.CMessage; @@ -287,7 +287,7 @@ public class CField implements ICDoc { final ArrayList choices2 = new ArrayList(); if (choices.isEmpty()) { - GuiUtils.chooseOneOrNone(this.title, new String[] { "no cards" }); + GuiChoose.oneOrNone(this.title, new String[] { "no cards" }); } else { for (int i = 0; i < choices.size(); i++) { final Card crd = choices.get(i); @@ -306,7 +306,7 @@ public class CField implements ICDoc { choices2.add(crd); } } - final Card choice = (Card) GuiUtils.chooseOneOrNone(this.title, choices2); + final Card choice = (Card) GuiChoose.oneOrNone(this.title, choices2); if (choice != null) { this.doAction(choice); }