GuiUtils.getChoice renamed to clear and simple names

added possibility to pass List<T> as options (to avoid useless list -> array -> list conversions)
This commit is contained in:
Maxmtg
2012-03-01 21:37:22 +00:00
parent e25a4d1eda
commit c98d037e0e
51 changed files with 412 additions and 415 deletions

2
.gitattributes vendored
View File

@@ -11179,7 +11179,7 @@ src/main/java/forge/card/abilityfactory/AbilityFactoryAlterLife.java svneol=nati
src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java svneol=native#text/plain src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java svneol=native#text/plain
src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java svneol=native#text/plain src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java svneol=native#text/plain
src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java svneol=native#text/plain src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java svneol=native#text/plain
src/main/java/forge/card/abilityfactory/AbilityFactoryCharm.java -text svneol=native#text/plain src/main/java/forge/card/abilityfactory/AbilityFactoryCharm.java svneol=native#text/plain
src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java svneol=native#text/plain src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java svneol=native#text/plain
src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java svneol=native#text/plain src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java svneol=native#text/plain
src/main/java/forge/card/abilityfactory/AbilityFactoryCleanup.java svneol=native#text/plain src/main/java/forge/card/abilityfactory/AbilityFactoryCleanup.java svneol=native#text/plain

View File

@@ -2759,7 +2759,7 @@ public class CombatUtil {
if (lib.size() > 0) { if (lib.size() > 0) {
final CardList cl = new CardList(); final CardList cl = new CardList();
cl.add(lib.get(0)); cl.add(lib.get(0));
GuiUtils.getChoiceOptional("Top card", cl.toArray()); GuiUtils.chooseOneOrNone("Top card", cl.toArray());
final Card top = lib.get(0); final Card top = lib.get(0);
if (top.isCreature()) { if (top.isCreature()) {
player.gainLife(top.getBaseDefense(), c); player.gainLife(top.getBaseDefense(), c);
@@ -3021,7 +3021,7 @@ public class CombatUtil {
final Card crd = enchantments.get(j); final Card crd = enchantments.get(j);
target[j] = crd; target[j] = crd;
} }
final Object check = GuiUtils.getChoiceOptional( final Object check = GuiUtils.chooseOneOrNone(
"Select enchantment to enchant exalted creature", target); "Select enchantment to enchant exalted creature", target);
if (check != null) { if (check != null) {
enchantment = ((Card) check); enchantment = ((Card) check);

View File

@@ -215,7 +215,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
} }
if (player.isHuman()) { if (player.isHuman()) {
final Object o = GuiUtils.getChoiceOptional( final Object o = GuiUtils.chooseOneOrNone(
"Select target creature for Wall of Reverence life gain", creats.toArray()); "Select target creature for Wall of Reverence life gain", creats.toArray());
if (o != null) { if (o != null) {
final Card c = (Card) o; final Card c = (Card) o;

View File

@@ -1123,7 +1123,7 @@ public class GameAction {
crd = list.get(0); crd = list.get(0);
} else { } else {
if (c.getController().isHuman()) { if (c.getController().isHuman()) {
crd = GuiUtils.getChoiceOptional("Select totem armor to destroy", list.toArray()); crd = GuiUtils.chooseOneOrNone("Select totem armor to destroy", list.toArray());
} else { } else {
crd = list.get(0); crd = list.get(0);
} }
@@ -1306,7 +1306,7 @@ public class GameAction {
crd = list.get(0); crd = list.get(0);
} else { } else {
if (c.getController().isHuman()) { if (c.getController().isHuman()) {
crd = GuiUtils.getChoiceOptional("Select totem armor to destroy", list.toArray()); crd = GuiUtils.chooseOneOrNone("Select totem armor to destroy", list.toArray());
} else { } else {
crd = list.get(0); crd = list.get(0);
} }
@@ -1413,7 +1413,7 @@ public class GameAction {
} else if (choices.size() == 1) { } else if (choices.size() == 1) {
choice = choices.get(0); choice = choices.get(0);
} else { } else {
choice = (String) GuiUtils.getChoiceOptional("Choose", choices.toArray()); choice = (String) GuiUtils.chooseOneOrNone("Choose", choices.toArray());
} }
if (choice == null) { if (choice == null) {
@@ -1451,7 +1451,7 @@ public class GameAction {
} else if (choices.size() == 1) { } else if (choices.size() == 1) {
sa = choices.get(0); sa = choices.get(0);
} else { } else {
sa = (SpellAbility) GuiUtils.getChoiceOptional("Choose", choices.toArray()); sa = (SpellAbility) GuiUtils.chooseOneOrNone("Choose", choices.toArray());
} }
if (sa == null) { if (sa == null) {
@@ -1592,12 +1592,12 @@ public class GameAction {
if (originalCard.getController().isHuman()) { if (originalCard.getController().isHuman()) {
final int chosenAmount = (Integer) GuiUtils final int chosenAmount = (Integer) GuiUtils
.getChoice("Exile how many cards?", choiceList.toArray()); .chooseOne("Exile how many cards?", choiceList.toArray());
System.out.println("Delve for " + chosenAmount); System.out.println("Delve for " + chosenAmount);
final CardList choices = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); final CardList choices = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard);
final CardList chosen = new CardList(); final CardList chosen = new CardList();
for (int i = 0; i < chosenAmount; i++) { for (int i = 0; i < chosenAmount; i++) {
final Card nowChosen = GuiUtils.getChoiceOptional("Exile which card?", choices.toArray()); final Card nowChosen = GuiUtils.chooseOneOrNone("Exile which card?", choices.toArray());
if (nowChosen == null) { if (nowChosen == null) {
// User canceled,abort delving. // User canceled,abort delving.
@@ -1674,7 +1674,7 @@ public class GameAction {
ManaCost newCost = new ManaCost(originalCost.toString()); ManaCost newCost = new ManaCost(originalCost.toString());
Object tapForConvoke = null; Object tapForConvoke = null;
if (sa.getActivatingPlayer().isHuman()) { if (sa.getActivatingPlayer().isHuman()) {
tapForConvoke = GuiUtils.getChoiceOptional("Tap for Convoke? " + newCost.toString(), tapForConvoke = GuiUtils.chooseOneOrNone("Tap for Convoke? " + newCost.toString(),
choices.toArray()); choices.toArray());
} else { } else {
// TODO: AI to choose a creature to tap would go here // TODO: AI to choose a creature to tap would go here
@@ -1689,7 +1689,7 @@ public class GameAction {
String chosenColor = usableColors.get(0); String chosenColor = usableColors.get(0);
if (usableColors.size() > 1) { if (usableColors.size() > 1) {
if (sa.getActivatingPlayer().isHuman()) { if (sa.getActivatingPlayer().isHuman()) {
chosenColor = (String) GuiUtils.getChoice("Convoke for which color?", chosenColor = (String) GuiUtils.chooseOne("Convoke for which color?",
usableColors.toArray()); usableColors.toArray());
} else { } else {
// TODO: AI for choosing which color to // TODO: AI for choosing which color to
@@ -1717,7 +1717,7 @@ public class GameAction {
} }
if (sa.getActivatingPlayer().isHuman()) { if (sa.getActivatingPlayer().isHuman()) {
tapForConvoke = GuiUtils.getChoiceOptional("Tap for Convoke? " + newCost.toString(), tapForConvoke = GuiUtils.chooseOneOrNone("Tap for Convoke? " + newCost.toString(),
choices.toArray()); choices.toArray());
} else { } else {
// TODO: AI to choose a creature to tap would go // TODO: AI to choose a creature to tap would go

View File

@@ -137,7 +137,7 @@ public final class GameActionUtil {
} }
} // while } // while
GuiUtils.getChoiceOptional("Revealed cards:", revealed.toArray()); GuiUtils.chooseOneOrNone("Revealed cards:", revealed.toArray());
if (cascadedCard != null) { if (cascadedCard != null) {
@@ -268,7 +268,7 @@ public final class GameActionUtil {
rippledCards[i] = crd; rippledCards[i] = crd;
} }
} // for } // for
GuiUtils.getChoiceOptional("Revealed cards:", revealed.toArray()); GuiUtils.chooseOneOrNone("Revealed cards:", revealed.toArray());
for (int i = 0; i < rippleMax; i++) { for (int i = 0; i < rippleMax; i++) {
if (rippledCards[i] != null) { if (rippledCards[i] != null) {
@@ -463,7 +463,7 @@ public final class GameActionUtil {
final boolean flip = MyRandom.getRandom().nextBoolean(); final boolean flip = MyRandom.getRandom().nextBoolean();
if (caller.isHuman()) { if (caller.isHuman()) {
choice = GuiUtils.getChoice(source.getName() + " - Call coin flip", choices); choice = GuiUtils.chooseOne(source.getName() + " - Call coin flip", choices);
} else { } else {
choice = choices[MyRandom.getRandom().nextInt(2)]; choice = choices[MyRandom.getRandom().nextInt(2)];
} }
@@ -505,7 +505,7 @@ public final class GameActionUtil {
Object q = null; Object q = null;
q = GuiUtils.getChoiceOptional("Use " + c + " Landfall?", choices); q = GuiUtils.chooseOneOrNone("Use " + c + " Landfall?", choices);
return (q != null) && q.equals("Yes"); return (q != null) && q.equals("Yes");
} }
@@ -524,7 +524,7 @@ public final class GameActionUtil {
public void resolve() { public void resolve() {
String color = ""; String color = "";
final Object o = GuiUtils.getChoice("Choose mana color", Constant.Color.ONLY_COLORS); final Object o = GuiUtils.chooseOne("Choose mana color", Constant.Color.ONLY_COLORS);
color = InputPayManaCostUtil.getShortColorString((String) o); color = InputPayManaCostUtil.getShortColorString((String) o);
final AbilityMana abMana = new AbilityMana(c, "0", color) { final AbilityMana abMana = new AbilityMana(c, "0", color) {

View File

@@ -1469,7 +1469,7 @@ public final class GuiDisplayUtil {
*/ */
public static void devModeTutor() { public static void devModeTutor() {
final CardList lib = AllZone.getHumanPlayer().getCardsIn(Zone.Library); final CardList lib = AllZone.getHumanPlayer().getCardsIn(Zone.Library);
final Object o = GuiUtils.getChoiceOptional("Choose a card", lib.toArray()); final Object o = GuiUtils.chooseOneOrNone("Choose a card", lib.toArray());
if (null == o) { if (null == o) {
return; return;
} else { } else {
@@ -1487,12 +1487,12 @@ public final class GuiDisplayUtil {
*/ */
public static void devModeAddCounter() { public static void devModeAddCounter() {
final CardList play = AllZoneUtil.getCardsIn(Zone.Battlefield); final CardList play = AllZoneUtil.getCardsIn(Zone.Battlefield);
final Object o = GuiUtils.getChoiceOptional("Add counters to which card?", play.toArray()); final Object o = GuiUtils.chooseOneOrNone("Add counters to which card?", play.toArray());
if (null == o) { if (null == o) {
return; return;
} else { } else {
final Card c = (Card) o; final Card c = (Card) o;
final Counters counter = GuiUtils.getChoiceOptional("Which type of counter?", Counters.values()); final Counters counter = GuiUtils.chooseOneOrNone("Which type of counter?", Counters.values());
if (null == counter) { if (null == counter) {
return; return;
} else { } else {
@@ -1500,7 +1500,7 @@ public final class GuiDisplayUtil {
for (int j = 0; j < 99; j++) { for (int j = 0; j < 99; j++) {
integers[j] = Integer.valueOf(j); integers[j] = Integer.valueOf(j);
} }
final Integer i = GuiUtils.getChoiceOptional("How many counters?", integers); final Integer i = GuiUtils.chooseOneOrNone("How many counters?", integers);
if (null == i) { if (null == i) {
return; return;
} else { } else {
@@ -1519,7 +1519,7 @@ public final class GuiDisplayUtil {
*/ */
public static void devModeTapPerm() { public static void devModeTapPerm() {
final CardList play = AllZoneUtil.getCardsIn(Zone.Battlefield); final CardList play = AllZoneUtil.getCardsIn(Zone.Battlefield);
final Object o = GuiUtils.getChoiceOptional("Choose a permanent", play.toArray()); final Object o = GuiUtils.chooseOneOrNone("Choose a permanent", play.toArray());
if (null == o) { if (null == o) {
return; return;
} else { } else {
@@ -1537,7 +1537,7 @@ public final class GuiDisplayUtil {
*/ */
public static void devModeUntapPerm() { public static void devModeUntapPerm() {
final CardList play = AllZoneUtil.getCardsIn(Zone.Battlefield); final CardList play = AllZoneUtil.getCardsIn(Zone.Battlefield);
final Object o = GuiUtils.getChoiceOptional("Choose a permanent", play.toArray()); final Object o = GuiUtils.chooseOneOrNone("Choose a permanent", play.toArray());
if (null == o) { if (null == o) {
return; return;
} else { } else {
@@ -1566,7 +1566,7 @@ public final class GuiDisplayUtil {
*/ */
public static void devModeSetLife() { public static void devModeSetLife() {
final List<Player> players = AllZone.getPlayersInGame(); final List<Player> players = AllZone.getPlayersInGame();
final Object o = GuiUtils.getChoiceOptional("Set life for which player?", players.toArray()); final Object o = GuiUtils.chooseOneOrNone("Set life for which player?", players.toArray());
if (null == o) { if (null == o) {
return; return;
} else { } else {
@@ -1575,7 +1575,7 @@ public final class GuiDisplayUtil {
for (int j = 0; j < 99; j++) { for (int j = 0; j < 99; j++) {
integers[j] = Integer.valueOf(j); integers[j] = Integer.valueOf(j);
} }
final Integer i = GuiUtils.getChoiceOptional("Set life to what?", integers); final Integer i = GuiUtils.chooseOneOrNone("Set life to what?", integers);
if (null == i) { if (null == i) {
return; return;
} else { } else {

View File

@@ -135,9 +135,9 @@ public class HumanPlayer extends Player {
public final boolean dredge() { public final boolean dredge() {
boolean dredged = false; boolean dredged = false;
final String[] choices = { "Yes", "No" }; final String[] choices = { "Yes", "No" };
final Object o = GuiUtils.getChoice("Do you want to dredge?", choices); final Object o = GuiUtils.chooseOne("Do you want to dredge?", choices);
if (o.equals("Yes")) { if (o.equals("Yes")) {
final Card c = GuiUtils.getChoice("Select card to dredge", this.getDredge().toArray()); final Card c = GuiUtils.chooseOne("Select card to dredge", this.getDredge().toArray());
// rule 702.49a // rule 702.49a
if (this.getDredgeNumber(c) <= AllZone.getHumanPlayer().getZone(Zone.Library).size()) { if (this.getDredgeNumber(c) <= AllZone.getHumanPlayer().getZone(Zone.Library).size()) {
@@ -198,7 +198,7 @@ public class HumanPlayer extends Player {
s += "s"; s += "s";
} }
final Object o = GuiUtils.getChoice("Do you want to put the " + s final Object o = GuiUtils.chooseOne("Do you want to put the " + s
+ " on the top or bottom of your library?", new Object[] { "top", "bottom" }); + " on the top or bottom of your library?", new Object[] { "top", "bottom" });
libPos = o.toString(); libPos = o.toString();
} }
@@ -210,7 +210,7 @@ public class HumanPlayer extends Player {
protected final void doScry(final CardList topN, final int n) { protected final void doScry(final CardList topN, final int n) {
int num = n; int num = n;
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
final Object o = GuiUtils.getChoiceOptional("Put on bottom of library.", topN.toArray()); final Object o = GuiUtils.chooseOneOrNone("Put on bottom of library.", topN.toArray());
if (o != null) { if (o != null) {
final Card c = (Card) o; final Card c = (Card) o;
topN.remove(c); topN.remove(c);
@@ -223,7 +223,7 @@ public class HumanPlayer extends Player {
num = topN.size(); num = topN.size();
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
Object o; Object o;
o = GuiUtils.getChoice("Put on top of library.", topN.toArray()); o = GuiUtils.chooseOne("Put on top of library.", topN.toArray());
if (o != null) { if (o != null) {
final Card c = (Card) o; final Card c = (Card) o;
topN.remove(c); topN.remove(c);
@@ -246,7 +246,7 @@ public class HumanPlayer extends Player {
String choice = ""; String choice = "";
final String[] choices = { "top", "bottom" }; final String[] choices = { "top", "bottom" };
Singletons.getControl().getControlMatch().setCard(c); Singletons.getControl().getControlMatch().setCard(c);
choice = GuiUtils.getChoice(c.getName() + " - Top or bottom of Library", choices); choice = GuiUtils.chooseOne(c.getName() + " - Top or bottom of Library", choices);
if (choice.equals("bottom")) { if (choice.equals("bottom")) {
Singletons.getModel().getGameAction().moveToBottomOfLibrary(c); Singletons.getModel().getGameAction().moveToBottomOfLibrary(c);

View File

@@ -1384,7 +1384,7 @@ public class MagicStack extends MyObservable {
} else { } else {
while (activePlayerSAs.size() > 1) { while (activePlayerSAs.size() > 1) {
final SpellAbility next = (SpellAbility) GuiUtils.getChoice( final SpellAbility next = (SpellAbility) GuiUtils.chooseOne(
"Choose which spell or ability to put on the stack next.", activePlayerSAs.toArray()); "Choose which spell or ability to put on the stack next.", activePlayerSAs.toArray());
activePlayerSAs.remove(next); activePlayerSAs.remove(next);

View File

@@ -1276,7 +1276,7 @@ public abstract class Player extends GameEntity {
} }
} }
if (reveal) { if (reveal) {
GuiUtils.getChoice("Revealing the first card drawn", drawn.toArray()); GuiUtils.chooseOne("Revealing the first card drawn", drawn.toArray());
} }
} }

View File

@@ -837,7 +837,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
private void revealTopCard(final String title) { private void revealTopCard(final String title) {
if (peek[0] != prevCardShown[0]) { if (peek[0] != prevCardShown[0]) {
GuiUtils.getChoice(title, peek[0]); GuiUtils.chooseOne(title, peek[0]);
prevCardShown[0] = peek[0]; prevCardShown[0] = peek[0];
} }
} // revealTopCard() } // revealTopCard()
@@ -939,7 +939,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
private void revealTopCard(final String title) { private void revealTopCard(final String title) {
if (peek[0] != prevCardShown[0]) { if (peek[0] != prevCardShown[0]) {
GuiUtils.getChoice(title, peek[0]); GuiUtils.chooseOne(title, peek[0]);
prevCardShown[0] = peek[0]; prevCardShown[0] = peek[0];
} }
} // revealTopCard() } // revealTopCard()
@@ -1039,7 +1039,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
private void revealTopCard(final String title) { private void revealTopCard(final String title) {
if (peek[0] != prevCardShown[0]) { if (peek[0] != prevCardShown[0]) {
GuiUtils.getChoice(title, peek[0]); GuiUtils.chooseOne(title, peek[0]);
prevCardShown[0] = peek[0]; prevCardShown[0] = peek[0];
} }
} // revealTopCard() } // revealTopCard()
@@ -1136,7 +1136,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
private void revealTopCard(final String title) { private void revealTopCard(final String title) {
if (peek[0] != prevCardShown[0]) { if (peek[0] != prevCardShown[0]) {
GuiUtils.getChoice(title, peek[0]); GuiUtils.chooseOne(title, peek[0]);
prevCardShown[0] = peek[0]; prevCardShown[0] = peek[0];
} }
} // revealTopCard() } // revealTopCard()
@@ -1221,7 +1221,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
private void revealTopCard(final String title) { private void revealTopCard(final String title) {
if (peek[0] != prevCardShown[0]) { if (peek[0] != prevCardShown[0]) {
GuiUtils.getChoice(title, peek[0]); GuiUtils.chooseOne(title, peek[0]);
prevCardShown[0] = peek[0]; prevCardShown[0] = peek[0];
} }
} // revealTopCard() } // revealTopCard()
@@ -1320,7 +1320,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
private void revealTopCard(final String title) { private void revealTopCard(final String title) {
if (peek[0] != prevCardShown[0]) { if (peek[0] != prevCardShown[0]) {
GuiUtils.getChoice(title, peek[0]); GuiUtils.chooseOne(title, peek[0]);
prevCardShown[0] = peek[0]; prevCardShown[0] = peek[0];
} }
} // revealTopCard() } // revealTopCard()
@@ -1412,7 +1412,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
private void revealTopCard(final String title) { private void revealTopCard(final String title) {
if (peek[0] != prevCardShown[0]) { if (peek[0] != prevCardShown[0]) {
GuiUtils.getChoice(title, peek[0]); GuiUtils.chooseOne(title, peek[0]);
prevCardShown[0] = peek[0]; prevCardShown[0] = peek[0];
} }
} // revealTopCard() } // revealTopCard()
@@ -1498,7 +1498,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
private void revealTopCard(final String title) { private void revealTopCard(final String title) {
if (peek[0] != prevCardShown[0]) { if (peek[0] != prevCardShown[0]) {
GuiUtils.getChoice(title, peek[0]); GuiUtils.chooseOne(title, peek[0]);
prevCardShown[0] = peek[0]; prevCardShown[0] = peek[0];
} }
} // revealTopCard() } // revealTopCard()
@@ -1582,7 +1582,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
private void revealTopCard(final String title) { private void revealTopCard(final String title) {
if (peek[0] != prevCardShown[0]) { if (peek[0] != prevCardShown[0]) {
GuiUtils.getChoice(title, peek[0]); GuiUtils.chooseOne(title, peek[0]);
prevCardShown[0] = peek[0]; prevCardShown[0] = peek[0];
} }
} // revealTopCard() } // revealTopCard()
@@ -1687,7 +1687,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
private void revealTopCard(final String title) { private void revealTopCard(final String title) {
if (peek[0] != prevCardShown[0]) { if (peek[0] != prevCardShown[0]) {
GuiUtils.getChoice(title, peek[0]); GuiUtils.chooseOne(title, peek[0]);
prevCardShown[0] = peek[0]; prevCardShown[0] = peek[0];
} }
} // revealTopCard() } // revealTopCard()
@@ -1771,7 +1771,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
private void revealTopCard(final String title) { private void revealTopCard(final String title) {
if (peek[0] != prevCardShown[0]) { if (peek[0] != prevCardShown[0]) {
GuiUtils.getChoice(title, peek[0]); GuiUtils.chooseOne(title, peek[0]);
prevCardShown[0] = peek[0]; prevCardShown[0] = peek[0];
} }
} // revealTopCard() } // revealTopCard()
@@ -1858,7 +1858,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
private void revealTopCard(final String title) { private void revealTopCard(final String title) {
if (peek[0] != prevCardShown[0]) { if (peek[0] != prevCardShown[0]) {
GuiUtils.getChoice(title, peek[0]); GuiUtils.chooseOne(title, peek[0]);
prevCardShown[0] = peek[0]; prevCardShown[0] = peek[0];
} }
} // revealTopCard() } // revealTopCard()
@@ -2046,7 +2046,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
} }
} // for loop } // for loop
if (cardsToReveal.size() > 0) { if (cardsToReveal.size() > 0) {
GuiUtils.getChoice("Revealed cards", cardsToReveal.toArray()); GuiUtils.chooseOne("Revealed cards", cardsToReveal.toArray());
} }
} }
} }
@@ -2090,7 +2090,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
if (AllZoneUtil.compareTypeAmountInGraveyard(player, "Creature") > 0) { if (AllZoneUtil.compareTypeAmountInGraveyard(player, "Creature") > 0) {
if (player.isHuman()) { if (player.isHuman()) {
final Object o = GuiUtils.getChoiceOptional("Pick a creature to return to hand", final Object o = GuiUtils.chooseOneOrNone("Pick a creature to return to hand",
graveyardCreatures.toArray()); graveyardCreatures.toArray());
if (o != null) { if (o != null) {
final Card card = (Card) o; final Card card = (Card) o;
@@ -2499,7 +2499,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
final Card crd = enchantmentsInLibrary.get(j); final Card crd = enchantmentsInLibrary.get(j);
target[j] = crd; target[j] = crd;
} }
final Object check = GuiUtils.getChoiceOptional("Select Curse to attach", target); final Object check = GuiUtils.chooseOneOrNone("Select Curse to attach", target);
if (check != null) { if (check != null) {
enchantment = ((Card) check); enchantment = ((Card) check);
} }

View File

@@ -1213,7 +1213,7 @@ public class AbilityFactoryAttach {
} }
} }
final Object o = GuiUtils.getChoice(source + " - Select a player to attach to.", players.toArray()); final Object o = GuiUtils.chooseOne(source + " - Select a player to attach to.", players);
if (o instanceof Player) { if (o instanceof Player) {
AbilityFactoryAttach.handleAura(source, (Player) o, false); AbilityFactoryAttach.handleAura(source, (Player) o, false);
//source.enchantEntity((Player) o); //source.enchantEntity((Player) o);
@@ -1223,7 +1223,7 @@ public class AbilityFactoryAttach {
CardList list = AllZoneUtil.getCardsIn(tgt.getZone()); CardList list = AllZoneUtil.getCardsIn(tgt.getZone());
list = list.getValidCards(tgt.getValidTgts(), aura.getActivatingPlayer(), source); list = list.getValidCards(tgt.getValidTgts(), aura.getActivatingPlayer(), source);
final Object o = GuiUtils.getChoice(source + " - Select a card to attach to.", list.toArray()); final Object o = GuiUtils.chooseOne(source + " - Select a card to attach to.", list.toArray());
if (o instanceof Card) { if (o instanceof Card) {
AbilityFactoryAttach.handleAura(source, (Card) o, gainControl); AbilityFactoryAttach.handleAura(source, (Card) o, gainControl);
//source.enchantEntity((Card) o); //source.enchantEntity((Card) o);

View File

@@ -870,13 +870,13 @@ public final class AbilityFactoryChangeZone {
// moving onto // moving onto
// choosing // choosing
// a card{ // a card{
GuiUtils.getChoiceOptional(af.getHostCard().getName() + " - Looking at Library", GuiUtils.chooseOneOrNone(af.getHostCard().getName() + " - Looking at Library",
player.getCardsIn(Zone.Library).toArray()); player.getCardsIn(Zone.Library).toArray());
} }
// Look at opponents hand before moving onto choosing a card // Look at opponents hand before moving onto choosing a card
if (origin.contains(Zone.Hand) && player.isComputer()) { if (origin.contains(Zone.Hand) && player.isComputer()) {
GuiUtils.getChoiceOptional(af.getHostCard().getName() + " - Looking at Opponent's Hand", player GuiUtils.chooseOneOrNone(af.getHostCard().getName() + " - Looking at Opponent's Hand", player
.getCardsIn(Zone.Hand).toArray()); .getCardsIn(Zone.Hand).toArray());
} }
fetchList = AbilityFactory.filterListByType(fetchList, params.get("ChangeType"), sa); fetchList = AbilityFactory.filterListByType(fetchList, params.get("ChangeType"), sa);
@@ -900,11 +900,11 @@ public final class AbilityFactoryChangeZone {
if (params.containsKey("AtRandom")) { if (params.containsKey("AtRandom")) {
o = CardUtil.getRandom(fetchList.toArray()); o = CardUtil.getRandom(fetchList.toArray());
} else if (params.containsKey("Mandatory")) { } else if (params.containsKey("Mandatory")) {
o = GuiUtils.getChoice("Select a card", fetchList.toArray()); o = GuiUtils.chooseOne("Select a card", fetchList.toArray());
} else if (params.containsKey("Defined")) { } else if (params.containsKey("Defined")) {
o = fetchList.get(0); o = fetchList.get(0);
} else { } else {
o = GuiUtils.getChoiceOptional("Select a card", fetchList.toArray()); o = GuiUtils.chooseOneOrNone("Select a card", fetchList.toArray());
} }
if (o != null) { if (o != null) {
@@ -916,7 +916,7 @@ public final class AbilityFactoryChangeZone {
// do not shuffle the library once we have placed a fetched // do not shuffle the library once we have placed a fetched
// card on top. // card on top.
if (params.containsKey("Reveal")) { if (params.containsKey("Reveal")) {
GuiUtils.getChoice(card + " - Revealed card: ", c); GuiUtils.chooseOne(card + " - Revealed card: ", c);
} }
if (origin.contains(Zone.Library) && (i < 1)) { if (origin.contains(Zone.Library) && (i < 1)) {
player.shuffle(); player.shuffle();
@@ -1166,9 +1166,9 @@ public final class AbilityFactoryChangeZone {
if (!Zone.Battlefield.equals(destination) && !"Card".equals(type) && !defined) { if (!Zone.Battlefield.equals(destination) && !"Card".equals(type) && !defined) {
final String picked = af.getHostCard().getName() + " - Computer picked:"; final String picked = af.getHostCard().getName() + " - Computer picked:";
if (fetched.size() > 0) { if (fetched.size() > 0) {
GuiUtils.getChoice(picked, fetched.toArray()); GuiUtils.chooseOne(picked, fetched.toArray());
} else { } else {
GuiUtils.getChoice(picked, new String[] { "<Nothing>" }); GuiUtils.chooseOne(picked, new String[] { "<Nothing>" });
} }
} }
} // end changeHiddenOriginResolveAI } // end changeHiddenOriginResolveAI

View File

@@ -161,9 +161,9 @@ public final class AbilityFactoryCharm {
for (int i = 0; i < sa.getCharmNumber(); i++) { for (int i = 0; i < sa.getCharmNumber(); i++) {
Object o; Object o;
if (i < sa.getMinCharmNumber()) { if (i < sa.getMinCharmNumber()) {
o = GuiUtils.getChoice("Choose a mode", choices.toArray()); o = GuiUtils.chooseOne("Choose a mode", choices.toArray());
} else { } else {
o = GuiUtils.getChoiceOptional("Choose a mode", choices.toArray()); o = GuiUtils.chooseOneOrNone("Choose a mode", choices.toArray());
} }
if (null == o) { if (null == o) {
break; break;

View File

@@ -309,7 +309,7 @@ public final class AbilityFactoryChoose {
while (!valid) { while (!valid) {
if (sa.getActivatingPlayer().isHuman()) { if (sa.getActivatingPlayer().isHuman()) {
final Object o = GuiUtils final Object o = GuiUtils
.getChoice("Choose a card type", CardUtil.getCardTypes().toArray()); .chooseOne("Choose a card type", CardUtil.getCardTypes().toArray());
if (null == o) { if (null == o) {
return; return;
} }
@@ -335,7 +335,7 @@ public final class AbilityFactoryChoose {
for (final String s : invalidTypes) { for (final String s : invalidTypes) {
validChoices.remove(s); validChoices.remove(s);
} }
final Object o = GuiUtils.getChoice("Choose a creature type", validChoices.toArray()); final Object o = GuiUtils.chooseOne("Choose a creature type", validChoices.toArray());
if (null == o) { if (null == o) {
return; return;
} }
@@ -372,7 +372,7 @@ public final class AbilityFactoryChoose {
if (!CardUtil.isACreatureType(chosen) || invalidTypes.contains(chosen)) { if (!CardUtil.isACreatureType(chosen) || invalidTypes.contains(chosen)) {
chosen = "Sliver"; chosen = "Sliver";
} }
GuiUtils.getChoice("Computer picked: ", chosen); GuiUtils.chooseOne("Computer picked: ", chosen);
chosenType = chosen; chosenType = chosen;
} }
if (CardUtil.isACreatureType(chosenType) && !invalidTypes.contains(chosenType)) { if (CardUtil.isACreatureType(chosenType) && !invalidTypes.contains(chosenType)) {
@@ -384,7 +384,7 @@ public final class AbilityFactoryChoose {
boolean valid = false; boolean valid = false;
while (!valid) { while (!valid) {
if (sa.getActivatingPlayer().isHuman()) { if (sa.getActivatingPlayer().isHuman()) {
final Object o = GuiUtils.getChoice("Choose a basic land type", CardUtil.getBasicTypes() final Object o = GuiUtils.chooseOne("Choose a basic land type", CardUtil.getBasicTypes()
.toArray()); .toArray());
if (null == o) { if (null == o) {
return; return;
@@ -404,7 +404,7 @@ public final class AbilityFactoryChoose {
while (!valid) { while (!valid) {
if (sa.getActivatingPlayer().isHuman()) { if (sa.getActivatingPlayer().isHuman()) {
final Object o = GuiUtils final Object o = GuiUtils
.getChoice("Choose a land type", CardUtil.getLandTypes().toArray()); .chooseOne("Choose a land type", CardUtil.getLandTypes().toArray());
if (null == o) { if (null == o) {
return; return;
} }
@@ -650,11 +650,11 @@ public final class AbilityFactoryChoose {
if ((tgt == null) || p.canBeTargetedBy(sa)) { if ((tgt == null) || p.canBeTargetedBy(sa)) {
if (sa.getActivatingPlayer().isHuman()) { if (sa.getActivatingPlayer().isHuman()) {
if (params.containsKey("OrColors")) { if (params.containsKey("OrColors")) {
final List<String> o = GuiUtils.getChoices("Choose a color or colors", final List<String> o = GuiUtils.chooseOneOrMany("Choose a color or colors",
Constant.Color.ONLY_COLORS); Constant.Color.ONLY_COLORS);
card.setChosenColor(new ArrayList<String>(o)); card.setChosenColor(new ArrayList<String>(o));
} else { } else {
final Object o = GuiUtils.getChoice("Choose a color", Constant.Color.ONLY_COLORS); final Object o = GuiUtils.chooseOne("Choose a color", Constant.Color.ONLY_COLORS);
if (null == o) { if (null == o) {
return; return;
} }
@@ -701,7 +701,7 @@ public final class AbilityFactoryChoose {
if (chosen.equals("")) { if (chosen.equals("")) {
chosen = Constant.Color.GREEN; chosen = Constant.Color.GREEN;
} }
GuiUtils.getChoice("Computer picked: ", chosen); GuiUtils.chooseOne("Computer picked: ", chosen);
final ArrayList<String> colorTemp = new ArrayList<String>(); final ArrayList<String> colorTemp = new ArrayList<String>();
colorTemp.add(chosen); colorTemp.add(chosen);
card.setChosenColor(colorTemp); card.setChosenColor(colorTemp);
@@ -942,7 +942,7 @@ public final class AbilityFactoryChoose {
final String message = "Randomly chosen number: " + chosen; final String message = "Randomly chosen number: " + chosen;
JOptionPane.showMessageDialog(null, message, "" + card, JOptionPane.PLAIN_MESSAGE); JOptionPane.showMessageDialog(null, message, "" + card, JOptionPane.PLAIN_MESSAGE);
} else { } else {
final Object o = GuiUtils.getChoice("Choose a number", choices); final Object o = GuiUtils.chooseOne("Choose a number", choices);
if (null == o) { if (null == o) {
return; return;
} }
@@ -1176,7 +1176,7 @@ public final class AbilityFactoryChoose {
for (final Player p : tgtPlayers) { for (final Player p : tgtPlayers) {
if ((tgt == null) || p.canBeTargetedBy(sa)) { if ((tgt == null) || p.canBeTargetedBy(sa)) {
if (sa.getActivatingPlayer().isHuman()) { if (sa.getActivatingPlayer().isHuman()) {
final Object o = GuiUtils.getChoice("Choose a player", choices.toArray()); final Object o = GuiUtils.chooseOne("Choose a player", choices.toArray());
if (null == o) { if (null == o) {
return; return;
} }
@@ -1496,7 +1496,7 @@ public final class AbilityFactoryChoose {
if (chosen == "") { if (chosen == "") {
chosen = "Morphling"; chosen = "Morphling";
} }
GuiUtils.getChoice("Computer picked: ", chosen); GuiUtils.chooseOne("Computer picked: ", chosen);
host.setNamedCard(chosen); host.setNamedCard(chosen);
ok = true; ok = true;
} }
@@ -1729,7 +1729,7 @@ public final class AbilityFactoryChoose {
final CardList cl = land.getType(type); final CardList cl = land.getType(type);
if (cl.size() > 0) { if (cl.size() > 0) {
final String prompt = "Choose a" + (type.equals("Island") ? "n " : " ") + type; final String prompt = "Choose a" + (type.equals("Island") ? "n " : " ") + type;
final Object o = GuiUtils.getChoice(prompt, cl.toArray()); final Object o = GuiUtils.chooseOne(prompt, cl.toArray());
if (null != o) { if (null != o) {
final Card c = (Card) o; final Card c = (Card) o;
chosen.add(c); chosen.add(c);
@@ -1949,7 +1949,7 @@ public final class AbilityFactoryChoose {
for (final Player p : tgtPlayers) { for (final Player p : tgtPlayers) {
if ((tgt == null) || p.canBeTargetedBy(sa)) { if ((tgt == null) || p.canBeTargetedBy(sa)) {
String choice = (String) GuiUtils.getChoice("Choose one", choices.values().toArray()); String choice = (String) GuiUtils.chooseOne("Choose one", choices.values().toArray());
AbilityFactory afChoice = new AbilityFactory(); AbilityFactory afChoice = new AbilityFactory();
final SpellAbility chosenSA = afChoice.getAbility(host.getSVar(choices.inverse().get(choice)), host); final SpellAbility chosenSA = afChoice.getAbility(host.getSVar(choices.inverse().get(choice)), host);

View File

@@ -696,7 +696,7 @@ public final class AbilityFactoryClash {
// first, separate the cards into piles // first, separate the cards into piles
if (separator.isHuman()) { if (separator.isHuman()) {
final List<Card> l = GuiUtils.getChoicesOptional("Put into pile 1 (multi-select)", pool.toArray()); final List<Card> l = GuiUtils.chooseNoneOrMany("Put into pile 1 (multi-select)", pool.toArray());
for (final Card c : l) { for (final Card c : l) {
pile1.add(c); pile1.add(c);
} }
@@ -753,7 +753,7 @@ public final class AbilityFactoryClash {
// make sure Pile 1 or Pile 2 is clicked on // make sure Pile 1 or Pile 2 is clicked on
boolean chosen = false; boolean chosen = false;
while (!chosen) { while (!chosen) {
final Object o = GuiUtils.getChoice("Choose a pile", disp); final Object o = GuiUtils.chooseOne("Choose a pile", disp);
final Card c = (Card) o; final Card c = (Card) o;
if (c.getName().equals("Pile 1")) { if (c.getName().equals("Pile 1")) {
chosen = true; chosen = true;

View File

@@ -743,7 +743,7 @@ public final class AbilityFactoryCopy {
if (tgtSpells.size() == 1) { if (tgtSpells.size() == 1) {
chosenSA = tgtSpells.get(0); chosenSA = tgtSpells.get(0);
} else if (sa.getActivatingPlayer().isHuman()) { } else if (sa.getActivatingPlayer().isHuman()) {
chosenSA = (SpellAbility) GuiUtils.getChoice("Select a spell to copy", tgtSpells.toArray()); chosenSA = (SpellAbility) GuiUtils.chooseOne("Select a spell to copy", tgtSpells.toArray());
} else { } else {
chosenSA = tgtSpells.get(0); chosenSA = tgtSpells.get(0);
} }

View File

@@ -698,7 +698,7 @@ public class AbilityFactoryCounters {
for (int j = 0; j <= counterAmount; j++) { for (int j = 0; j <= counterAmount; j++) {
integers[j] = Integer.valueOf(j); integers[j] = Integer.valueOf(j);
} }
final Integer i = GuiUtils.getChoiceOptional("How many counters?", integers); final Integer i = GuiUtils.chooseOneOrNone("How many counters?", integers);
if (null == i) { if (null == i) {
return; return;
} else { } else {
@@ -1125,7 +1125,7 @@ public class AbilityFactoryCounters {
} }
if (typeChoices.size() > 1) { if (typeChoices.size() > 1) {
String prompt = "Select type counters to remove"; String prompt = "Select type counters to remove";
o = GuiUtils.getChoice(prompt, typeChoices.toArray()); o = GuiUtils.chooseOne(prompt, typeChoices.toArray());
} }
else { else {
o = typeChoices.get(0); o = typeChoices.get(0);
@@ -1141,7 +1141,7 @@ public class AbilityFactoryCounters {
choices.add("" + i); choices.add("" + i);
} }
String prompt = "Select the number of " + chosenType.getName() + " counters to remove"; String prompt = "Select the number of " + chosenType.getName() + " counters to remove";
o = GuiUtils.getChoice(prompt, choices.toArray()); o = GuiUtils.chooseOne(prompt, choices.toArray());
chosenAmount = Integer.parseInt((String) o); chosenAmount = Integer.parseInt((String) o);
} }
} }
@@ -1177,7 +1177,7 @@ public class AbilityFactoryCounters {
choices.add("" + i); choices.add("" + i);
} }
final String prompt = "Select the number of " + type + " counters to remove"; final String prompt = "Select the number of " + type + " counters to remove";
final Object o = GuiUtils.getChoice(prompt, choices.toArray()); final Object o = GuiUtils.chooseOne(prompt, choices.toArray());
counterAmount = Integer.parseInt((String) o); counterAmount = Integer.parseInt((String) o);
} }
} }
@@ -1436,7 +1436,7 @@ public class AbilityFactoryCounters {
} }
if (choices.size() > 0) { if (choices.size() > 0) {
card.addCounter( card.addCounter(
Counters.getType((choices.size() == 1 ? choices.get(0) : GuiUtils.getChoice( Counters.getType((choices.size() == 1 ? choices.get(0) : GuiUtils.chooseOne(
"Select counter type", choices.toArray()).toString())), 1); "Select counter type", choices.toArray()).toString())), 1);
} }
} }

View File

@@ -317,7 +317,7 @@ public class AbilityFactoryMana {
else { else {
colorMenu = Constant.Color.ONLY_COLORS; colorMenu = Constant.Color.ONLY_COLORS;
} }
Object o = GuiUtils.getChoice("Select Mana to Produce", colorMenu); Object o = GuiUtils.chooseOne("Select Mana to Produce", colorMenu);
if (o == null) { if (o == null) {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append("AbilityFactoryMana::manaResolve() - Human color mana choice is empty for "); sb.append("AbilityFactoryMana::manaResolve() - Human color mana choice is empty for ");
@@ -337,7 +337,7 @@ public class AbilityFactoryMana {
chosen = CardFactoryUtil.getMostProminentColor(AllZone.getComputerPlayer().getCardsIn( chosen = CardFactoryUtil.getMostProminentColor(AllZone.getComputerPlayer().getCardsIn(
Zone.Hand)); Zone.Hand));
} }
GuiUtils.getChoice("Computer picked: ", chosen); GuiUtils.chooseOne("Computer picked: ", chosen);
abMana.setExpressChoice(InputPayManaCostUtil.getShortColorString(chosen)); abMana.setExpressChoice(InputPayManaCostUtil.getShortColorString(chosen));
} }
if (abMana.getExpressChoice().isEmpty()) { if (abMana.getExpressChoice().isEmpty()) {
@@ -806,7 +806,7 @@ public class AbilityFactoryMana {
baseMana = InputPayManaCostUtil.getShortColorString(colors.get(0)); baseMana = InputPayManaCostUtil.getShortColorString(colors.get(0));
} else { } else {
if (player.isHuman()) { if (player.isHuman()) {
final Object o = GuiUtils.getChoiceOptional("Select Mana to Produce", colors.toArray()); final Object o = GuiUtils.chooseOneOrNone("Select Mana to Produce", colors.toArray());
if (o == null) { if (o == null) {
// User hit cancel // User hit cancel
abMana.setCanceled(true); abMana.setCanceled(true);

View File

@@ -2054,7 +2054,7 @@ public class AbilityFactoryPermanentState {
if (AllZoneUtil.isCardInPlay(tgtC) && ((tgt == null) || tgtC.canBeTargetedBy(sa))) { if (AllZoneUtil.isCardInPlay(tgtC) && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
if (sa.getActivatingPlayer().isHuman()) { if (sa.getActivatingPlayer().isHuman()) {
final String[] tapOrUntap = new String[] { "Tap", "Untap" }; final String[] tapOrUntap = new String[] { "Tap", "Untap" };
final Object z = GuiUtils.getChoiceOptional("Tap or Untap " + tgtC + "?", tapOrUntap); final Object z = GuiUtils.chooseOneOrNone("Tap or Untap " + tgtC + "?", tapOrUntap);
if (null == z) { if (null == z) {
continue; continue;
} }

View File

@@ -360,7 +360,7 @@ public final class AbilityFactoryPlay {
Card tgtCard = tgtCards.get(0); Card tgtCard = tgtCards.get(0);
if (tgtCards.size() > 1) { if (tgtCards.size() > 1) {
if (controller.isHuman()) { if (controller.isHuman()) {
tgtCard = (Card) GuiUtils.getChoice("Select a card to play", tgtCards.toArray()); tgtCard = (Card) GuiUtils.chooseOne("Select a card to play", tgtCards.toArray());
} else { } else {
// AI // AI
tgtCards = tgtCards.filter(new CardListFilter() { tgtCards = tgtCards.filter(new CardListFilter() {
@@ -420,7 +420,7 @@ public final class AbilityFactoryPlay {
if (sas.size() == 1) { if (sas.size() == 1) {
tgtSA = sas.get(0); tgtSA = sas.get(0);
} else if (sa.getActivatingPlayer().isHuman()) { } else if (sa.getActivatingPlayer().isHuman()) {
tgtSA = (SpellAbility) GuiUtils.getChoice("Select a spell to cast", sas.toArray()); tgtSA = (SpellAbility) GuiUtils.chooseOne("Select a spell to cast", sas.toArray());
} else { } else {
tgtSA = sas.get(0); tgtSA = sas.get(0);
} }

View File

@@ -694,7 +694,7 @@ public final class AbilityFactoryProtection {
final ArrayList<String> gains = new ArrayList<String>(); final ArrayList<String> gains = new ArrayList<String>();
if (isChoice) { if (isChoice) {
if (sa.getActivatingPlayer().isHuman()) { if (sa.getActivatingPlayer().isHuman()) {
final Object o = GuiUtils.getChoice("Choose a protection", choices.toArray()); final Object o = GuiUtils.chooseOne("Choose a protection", choices.toArray());
if (null == o) { if (null == o) {
return; return;
@@ -1084,7 +1084,7 @@ public final class AbilityFactoryProtection {
final ArrayList<String> gains = new ArrayList<String>(); final ArrayList<String> gains = new ArrayList<String>();
if (isChoice) { if (isChoice) {
if (sa.getActivatingPlayer().isHuman()) { if (sa.getActivatingPlayer().isHuman()) {
final Object o = GuiUtils.getChoice("Choose a protection", choices.toArray()); final Object o = GuiUtils.chooseOne("Choose a protection", choices.toArray());
if (null == o) { if (null == o) {
return; return;

View File

@@ -397,7 +397,7 @@ public final class AbilityFactoryReveal {
boolean cardsRevealed = false; boolean cardsRevealed = false;
if (params.containsKey("Reveal")) { if (params.containsKey("Reveal")) {
GuiUtils.getChoice("Revealing cards from library", top.toArray()); GuiUtils.chooseOne("Revealing cards from library", top.toArray());
cardsRevealed = true; cardsRevealed = true;
// Singletons.getModel().getGameAction().revealToCopmuter(top.toArray()); // Singletons.getModel().getGameAction().revealToCopmuter(top.toArray());
// - for when it exists // - for when it exists
@@ -407,18 +407,18 @@ public final class AbilityFactoryReveal {
question += c + " "; question += c + " ";
} }
if (p.isHuman() && GameActionUtil.showYesNoDialog(host, question)) { if (p.isHuman() && GameActionUtil.showYesNoDialog(host, question)) {
GuiUtils.getChoice(host + "Revealing cards from library", top.toArray()); GuiUtils.chooseOne(host + "Revealing cards from library", top.toArray());
// Singletons.getModel().getGameAction().revealToCopmuter(top.toArray()); // Singletons.getModel().getGameAction().revealToCopmuter(top.toArray());
cardsRevealed = true; cardsRevealed = true;
} else if (p.isComputer() && (top.get(0).isInstant() || top.get(0).isSorcery())) { } else if (p.isComputer() && (top.get(0).isInstant() || top.get(0).isSorcery())) {
GuiUtils.getChoice(host + "Revealing cards from library", top.toArray()); GuiUtils.chooseOne(host + "Revealing cards from library", top.toArray());
cardsRevealed = true; cardsRevealed = true;
} }
} else if (params.containsKey("RevealValid")) { } else if (params.containsKey("RevealValid")) {
final String revealValid = params.get("RevealValid"); final String revealValid = params.get("RevealValid");
final CardList toReveal = top.getValidCards(revealValid, host.getController(), host); final CardList toReveal = top.getValidCards(revealValid, host.getController(), host);
if (!toReveal.isEmpty()) { if (!toReveal.isEmpty()) {
GuiUtils.getChoice("Revealing cards from library", toReveal.toArray()); GuiUtils.chooseOne("Revealing cards from library", toReveal.toArray());
if (params.containsKey("RememberRevealed")) { if (params.containsKey("RememberRevealed")) {
for (final Card one : toReveal) { for (final Card one : toReveal) {
host.addRemembered(one); host.addRemembered(one);
@@ -429,7 +429,7 @@ public final class AbilityFactoryReveal {
// - for when it exists // - for when it exists
} else if (choser.isHuman()) { } else if (choser.isHuman()) {
// show the user the revealed cards // show the user the revealed cards
GuiUtils.getChoice("Looking at cards from library", top.toArray()); GuiUtils.chooseOne("Looking at cards from library", top.toArray());
cardsRevealed = true; cardsRevealed = true;
} }
@@ -499,9 +499,9 @@ public final class AbilityFactoryReveal {
prompt = "Chose a card to put on top of the "; prompt = "Chose a card to put on top of the ";
} }
if (anyNumber || optional) { if (anyNumber || optional) {
chosen = GuiUtils.getChoiceOptional(prompt + destZone1, valid.toArray()); chosen = GuiUtils.chooseOneOrNone(prompt + destZone1, valid.toArray());
} else { } else {
chosen = GuiUtils.getChoice(prompt + destZone1, valid.toArray()); chosen = GuiUtils.chooseOne(prompt + destZone1, valid.toArray());
} }
if ((chosen == null) || chosen.getName().equals("[No valid cards]")) { if ((chosen == null) || chosen.getName().equals("[No valid cards]")) {
break; break;
@@ -552,7 +552,7 @@ public final class AbilityFactoryReveal {
} }
} }
if (changeValid.length() > 0) { if (changeValid.length() > 0) {
GuiUtils.getChoice("Computer picked: ", chosen); GuiUtils.chooseOne("Computer picked: ", chosen);
} }
valid.remove(chosen); valid.remove(chosen);
} }
@@ -579,7 +579,7 @@ public final class AbilityFactoryReveal {
if (libraryPosition2 == -1) { if (libraryPosition2 == -1) {
prompt = "Put the rest on the bottom of the library in any order"; prompt = "Put the rest on the bottom of the library in any order";
} }
chosen = GuiUtils.getChoice(prompt, rest.toArray()); chosen = GuiUtils.chooseOne(prompt, rest.toArray());
} else { } else {
chosen = rest.get(0); chosen = rest.get(0);
} }
@@ -975,7 +975,7 @@ public final class AbilityFactoryReveal {
} }
if (revealed.size() > 0) { if (revealed.size() > 0) {
GuiUtils.getChoice(p + " revealed: ", revealed.toArray()); GuiUtils.chooseOne(p + " revealed: ", revealed.toArray());
} }
// TODO Allow Human to choose the order // TODO Allow Human to choose the order
@@ -1327,7 +1327,7 @@ public final class AbilityFactoryReveal {
final CardList hand = p.getCardsIn(Zone.Hand); final CardList hand = p.getCardsIn(Zone.Hand);
if (sa.getActivatingPlayer().isHuman()) { if (sa.getActivatingPlayer().isHuman()) {
if (hand.size() > 0) { if (hand.size() > 0) {
GuiUtils.getChoice(p + "'s hand", hand.toArray()); GuiUtils.chooseOne(p + "'s hand", hand.toArray());
} else { } else {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append(p).append("'s hand is empty!"); sb.append(p).append("'s hand is empty!");
@@ -1916,7 +1916,7 @@ public final class AbilityFactoryReveal {
suffix = "th"; suffix = "th";
} }
final String title = "Put " + i + suffix + " from the top: "; final String title = "Put " + i + suffix + " from the top: ";
final Object o = GuiUtils.getChoiceOptional(title, topCards.toArray()); final Object o = GuiUtils.chooseOneOrNone(title, topCards.toArray());
if (o == null) { if (o == null) {
break; break;
} }
@@ -2215,7 +2215,7 @@ public final class AbilityFactoryReveal {
final CardList revealed = new CardList(); final CardList revealed = new CardList();
if (params.containsKey("Random")) { if (params.containsKey("Random")) {
revealed.add(CardUtil.getRandom(handChoices.toArray())); revealed.add(CardUtil.getRandom(handChoices.toArray()));
GuiUtils.getChoice("Revealed card(s)", revealed.toArray()); GuiUtils.chooseOne("Revealed card(s)", revealed.toArray());
} else { } else {
CardList valid = new CardList(handChoices); CardList valid = new CardList(handChoices);
int max = 1; int max = 1;
@@ -2226,7 +2226,7 @@ public final class AbilityFactoryReveal {
max = valid.size(); max = valid.size();
} }
revealed.addAll(AbilityFactoryReveal.getRevealedList(sa.getActivatingPlayer(), valid, max)); revealed.addAll(AbilityFactoryReveal.getRevealedList(sa.getActivatingPlayer(), valid, max));
GuiUtils.getChoice("Revealed card(s)", revealed.toArray()); GuiUtils.chooseOne("Revealed card(s)", revealed.toArray());
} }
if (params.containsKey("RememberRevealed")) { if (params.containsKey("RememberRevealed")) {
@@ -2254,7 +2254,7 @@ public final class AbilityFactoryReveal {
for (int i = 0; i < validamount; i++) { for (int i = 0; i < validamount; i++) {
if (player.isHuman()) { if (player.isHuman()) {
final Object o = GuiUtils.getChoiceOptional("Choose card(s) to reveal", valid.toArray()); final Object o = GuiUtils.chooseOneOrNone("Choose card(s) to reveal", valid.toArray());
if (o != null) { if (o != null) {
chosen.add((Card) o); chosen.add((Card) o);
valid.remove((Card) o); valid.remove((Card) o);

View File

@@ -532,9 +532,9 @@ public class AbilityFactorySacrifice {
} }
Object o; Object o;
if (optional) { if (optional) {
o = GuiUtils.getChoiceOptional("Select a card to sacrifice", list.toArray()); o = GuiUtils.chooseOneOrNone("Select a card to sacrifice", list.toArray());
} else { } else {
o = GuiUtils.getChoice("Select a card to sacrifice", list.toArray()); o = GuiUtils.chooseOne("Select a card to sacrifice", list.toArray());
} }
if (o != null) { if (o != null) {
final Card c = (Card) o; final Card c = (Card) o;

View File

@@ -569,7 +569,7 @@ public class AbilityFactoryZoneAffecting {
} else { } else {
final CardList drawn = p.drawCards(numCards); final CardList drawn = p.drawCards(numCards);
if (params.containsKey("Reveal")) { if (params.containsKey("Reveal")) {
GuiUtils.getChoice("Revealing drawn cards", drawn.toArray()); GuiUtils.chooseOne("Revealing drawn cards", drawn.toArray());
} }
if (params.containsKey("RememberDrawn")) { if (params.containsKey("RememberDrawn")) {
for (final Card c : drawn) { for (final Card c : drawn) {
@@ -1201,7 +1201,7 @@ public class AbilityFactoryZoneAffecting {
if (p.isHuman()) { if (p.isHuman()) {
// "reveal to computer" for information gathering // "reveal to computer" for information gathering
} else { } else {
GuiUtils.getChoiceOptional("Revealed computer hand", dPHand.toArray()); GuiUtils.chooseOneOrNone("Revealed computer hand", dPHand.toArray());
} }
String valid = params.get("DiscardValid"); String valid = params.get("DiscardValid");
@@ -1269,7 +1269,7 @@ public class AbilityFactoryZoneAffecting {
if (mode.startsWith("Reveal")) { if (mode.startsWith("Reveal")) {
final CardList dCs = new CardList(); final CardList dCs = new CardList();
dCs.add(dC); dCs.add(dC);
GuiUtils.getChoiceOptional("Computer has chosen", dCs.toArray()); GuiUtils.chooseOneOrNone("Computer has chosen", dCs.toArray());
} }
discarded.add(dC); discarded.add(dC);
p.discard(dC, sa); p.discard(dC, sa);
@@ -1278,17 +1278,17 @@ public class AbilityFactoryZoneAffecting {
} else { } else {
// human // human
if (mode.startsWith("Reveal")) { if (mode.startsWith("Reveal")) {
GuiUtils.getChoiceOptional("Revealed " + p + " hand", dPHand.toArray()); GuiUtils.chooseOneOrNone("Revealed " + p + " hand", dPHand.toArray());
} }
for (int i = 0; i < numCards; i++) { for (int i = 0; i < numCards; i++) {
if (dPChHand.size() > 0) { if (dPChHand.size() > 0) {
Card dC = null; Card dC = null;
if (params.containsKey("Optional")) { if (params.containsKey("Optional")) {
dC = GuiUtils.getChoiceOptional("Choose a card to be discarded", dC = GuiUtils.chooseOneOrNone("Choose a card to be discarded",
dPChHand.toArray()); dPChHand.toArray());
} else { } else {
dC = GuiUtils.getChoice("Choose a card to be discarded", dC = GuiUtils.chooseOne("Choose a card to be discarded",
dPChHand.toArray()); dPChHand.toArray());
} if (dC != null) { } if (dC != null) {
dPChHand.remove(dC); dPChHand.remove(dC);

View File

@@ -559,7 +559,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
imageName = "B 1 1 Thrull"; imageName = "B 1 1 Thrull";
color = "B"; color = "B";
} else if (player.isHuman()) { } else if (player.isHuman()) {
final Object q = GuiUtils.getChoiceOptional("Select type of creature", choices); final Object q = GuiUtils.chooseOneOrNone("Select type of creature", choices);
if (q != null) { if (q != null) {
if (q.equals("Citizen")) { if (q.equals("Citizen")) {
type = "Citizen"; type = "Citizen";
@@ -684,7 +684,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
chooseGrave.addAll(grave); chooseGrave.addAll(grave);
} }
final Object o = GuiUtils.getChoice("Choose first creature to exile", chooseGrave.toArray()); final Object o = GuiUtils.chooseOne("Choose first creature to exile", chooseGrave.toArray());
if (o != null) { if (o != null) {
CardList newGrave; CardList newGrave;
final Card c = (Card) o; final Card c = (Card) o;
@@ -697,7 +697,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
newGrave = newGrave.getType("Creature"); newGrave = newGrave.getType("Creature");
newGrave.remove(c); newGrave.remove(c);
final Object o2 = GuiUtils.getChoice("Choose second creature to exile", newGrave.toArray()); final Object o2 = GuiUtils.chooseOne("Choose second creature to exile", newGrave.toArray());
if (o2 != null) { if (o2 != null) {
final Card c2 = (Card) o2; final Card c2 = (Card) o2;
newGrave.remove(c2); newGrave.remove(c2);
@@ -989,7 +989,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
} }
} }
} // while } // while
GuiUtils.getChoiceOptional("Revealed cards:", revealed.toArray()); GuiUtils.chooseOneOrNone("Revealed cards:", revealed.toArray());
for (final Card revealedCard : revealed) { for (final Card revealedCard : revealed) {
Singletons.getModel().getGameAction().moveToBottomOfLibrary(revealedCard); Singletons.getModel().getGameAction().moveToBottomOfLibrary(revealedCard);
} }
@@ -1066,7 +1066,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
if (i == 4) { if (i == 4) {
title = "Put fourth from top of library: "; title = "Put fourth from top of library: ";
} }
final Object o = GuiUtils.getChoiceOptional(title, lands.toArray()); final Object o = GuiUtils.chooseOneOrNone(title, lands.toArray());
if (o == null) { if (o == null) {
break; break;
} }
@@ -1190,7 +1190,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
for (int j = 0; j <= num; j++) { for (int j = 0; j <= num; j++) {
choices[j] = "" + j; choices[j] = "" + j;
} }
final String answer = (GuiUtils.getChoiceOptional("Life to pay:", choices)); final String answer = (GuiUtils.chooseOneOrNone("Life to pay:", choices));
lifeToPay = Integer.parseInt(answer); lifeToPay = Integer.parseInt(answer);
} else { } else {
// not implemented for Compy // not implemented for Compy
@@ -1264,7 +1264,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
// Then look at the exiled cards and put them on // Then look at the exiled cards and put them on
// top of your library in any order. // top of your library in any order.
while (this.exiled.size() > 0) { while (this.exiled.size() > 0) {
final Object o = GuiUtils.getChoice("Put a card on top of your library.", final Object o = GuiUtils.chooseOne("Put a card on top of your library.",
this.exiled.toArray()); this.exiled.toArray());
final Card c1 = (Card) o; final Card c1 = (Card) o;
Singletons.getModel().getGameAction().moveToLibrary(c1); Singletons.getModel().getGameAction().moveToLibrary(c1);

View File

@@ -125,7 +125,7 @@ class CardFactoryAuras {
public void resolve() { public void resolve() {
// Only query player, AI will have decided already. // Only query player, AI will have decided already.
if (card.getController().isHuman()) { if (card.getController().isHuman()) {
newType[0] = GuiUtils.getChoice("Select land type.", "Plains", "Island", "Swamp", "Mountain", newType[0] = GuiUtils.chooseOne("Select land type.", "Plains", "Island", "Swamp", "Mountain",
"Forest"); "Forest");
} }
Singletons.getModel().getGameAction().moveToPlay(card); Singletons.getModel().getGameAction().moveToPlay(card);

View File

@@ -271,7 +271,7 @@ public class CardFactoryCreatures {
final String[] choices = { "3/3", "2/2 with flying", "1/6 with defender" }; final String[] choices = { "3/3", "2/2 with flying", "1/6 with defender" };
if (card.getController().isHuman()) { if (card.getController().isHuman()) {
choice = GuiUtils.getChoice("Choose one", choices); choice = GuiUtils.chooseOne("Choose one", choices);
} else { } else {
choice = choices[MyRandom.getRandom().nextInt(3)]; choice = choices[MyRandom.getRandom().nextInt(3)];
} }
@@ -630,7 +630,7 @@ public class CardFactoryCreatures {
if (card.getController().isHuman()) { if (card.getController().isHuman()) {
final String[] colors = Constant.Color.ONLY_COLORS; final String[] colors = Constant.Color.ONLY_COLORS;
final Object o = GuiUtils.getChoice("Choose color", colors); final Object o = GuiUtils.chooseOne("Choose color", colors);
color[0] = (String) o; color[0] = (String) o;
} else { } else {
// AI chooses the color that appears in the keywords of // AI chooses the color that appears in the keywords of
@@ -831,7 +831,7 @@ public class CardFactoryCreatures {
int lifeGain = 0; int lifeGain = 0;
if (card.getController().isHuman()) { if (card.getController().isHuman()) {
final String[] choices = { "white", "blue", "black", "red", "green" }; final String[] choices = { "white", "blue", "black", "red", "green" };
final Object o = GuiUtils.getChoiceOptional("Select Color: ", choices); final Object o = GuiUtils.chooseOneOrNone("Select Color: ", choices);
Log.debug("Treva, the Renewer", "Color:" + o); Log.debug("Treva, the Renewer", "Color:" + o);
lifeGain = CardFactoryUtil.getNumberOfPermanentsByColor((String) o); lifeGain = CardFactoryUtil.getNumberOfPermanentsByColor((String) o);
@@ -874,7 +874,7 @@ public class CardFactoryCreatures {
final CardList cl = new CardList(); final CardList cl = new CardList();
cl.add(lib.get(0)); cl.add(lib.get(0));
GuiUtils.getChoiceOptional("Top card", cl.toArray()); GuiUtils.chooseOneOrNone("Top card", cl.toArray());
} }
@Override @Override
@@ -1178,7 +1178,7 @@ public class CardFactoryCreatures {
list = list.getType("Enchantment"); list = list.getType("Enchantment");
if (list.size() > 0) { if (list.size() > 0) {
final Object objectSelected = GuiUtils.getChoiceOptional("Choose an enchantment", final Object objectSelected = GuiUtils.chooseOneOrNone("Choose an enchantment",
list.toArray()); list.toArray());
if (objectSelected != null) { if (objectSelected != null) {
@@ -1520,7 +1520,7 @@ public class CardFactoryCreatures {
if (card.getController().isHuman()) { if (card.getController().isHuman()) {
if (creats.size() > 0) { if (creats.size() > 0) {
final List<Card> selection = GuiUtils.getChoicesOptional("Select creatures to sacrifice", final List<Card> selection = GuiUtils.chooseNoneOrMany("Select creatures to sacrifice",
creats.toArray()); creats.toArray());
numCreatures[0] = selection.size(); numCreatures[0] = selection.size();
@@ -1600,7 +1600,7 @@ public class CardFactoryCreatures {
life[i] = String.valueOf(i); life[i] = String.valueOf(i);
} }
final Object o = GuiUtils.getChoice("Nameless Race - pay X life", life); final Object o = GuiUtils.chooseOne("Nameless Race - pay X life", life);
final String answer = (String) o; final String answer = (String) o;
int loseLife = 0; int loseLife = 0;
try { try {
@@ -2125,7 +2125,7 @@ public class CardFactoryCreatures {
public void showMessage() { public void showMessage() {
final String message = "Select a creature in a graveyard"; final String message = "Select a creature in a graveyard";
final CardList choices = AllZoneUtil.getCardsIn(Zone.Graveyard); final CardList choices = AllZoneUtil.getCardsIn(Zone.Graveyard);
final Object o = GuiUtils.getChoiceOptional(message, choices.toArray()); final Object o = GuiUtils.chooseOneOrNone(message, choices.toArray());
if (null == o) { if (null == o) {
this.stop(); this.stop();
} else { } else {
@@ -2179,9 +2179,9 @@ public class CardFactoryCreatures {
hand.remove(random); hand.remove(random);
} }
if (!revealed.isEmpty()) { if (!revealed.isEmpty()) {
GuiUtils.getChoice("Revealed at random", revealed.toArray()); GuiUtils.chooseOne("Revealed at random", revealed.toArray());
} else { } else {
GuiUtils.getChoice("Revealed at random", new String[] { "Nothing to reveal" }); GuiUtils.chooseOne("Revealed at random", new String[] { "Nothing to reveal" });
} }
for (final Card c : revealed) { for (final Card c : revealed) {

View File

@@ -290,7 +290,7 @@ public class CardFactoryInstants {
final CardList libraryList = AllZone.getHumanPlayer().getCardsIn(Zone.Library); final CardList libraryList = AllZone.getHumanPlayer().getCardsIn(Zone.Library);
final CardList selectedCards = new CardList(); final CardList selectedCards = new CardList();
Object o = GuiUtils.getChoiceOptional("Select first card", libraryList.toArray()); Object o = GuiUtils.chooseOneOrNone("Select first card", libraryList.toArray());
if (o != null) { if (o != null) {
final Card c1 = (Card) o; final Card c1 = (Card) o;
libraryList.remove(c1); libraryList.remove(c1);
@@ -298,7 +298,7 @@ public class CardFactoryInstants {
} else { } else {
return; return;
} }
o = GuiUtils.getChoiceOptional("Select second card", libraryList.toArray()); o = GuiUtils.chooseOneOrNone("Select second card", libraryList.toArray());
if (o != null) { if (o != null) {
final Card c2 = (Card) o; final Card c2 = (Card) o;
libraryList.remove(c2); libraryList.remove(c2);
@@ -306,7 +306,7 @@ public class CardFactoryInstants {
} else { } else {
return; return;
} }
o = GuiUtils.getChoiceOptional("Select third card", libraryList.toArray()); o = GuiUtils.chooseOneOrNone("Select third card", libraryList.toArray());
if (o != null) { if (o != null) {
final Card c3 = (Card) o; final Card c3 = (Card) o;
libraryList.remove(c3); libraryList.remove(c3);
@@ -354,7 +354,7 @@ public class CardFactoryInstants {
// NOTE: Using getChoiceOptional() results in a null error // NOTE: Using getChoiceOptional() results in a null error
// when you click on Cancel. // when you click on Cancel.
final Object o = GuiUtils.getChoice("Select card to give to computer", selectedCards.toArray()); final Object o = GuiUtils.chooseOne("Select card to give to computer", selectedCards.toArray());
final Card choice = (Card) o; final Card choice = (Card) o;
@@ -401,7 +401,7 @@ public class CardFactoryInstants {
if (player.isHuman()) { if (player.isHuman()) {
for (int i = 0; i < x; i++) { for (int i = 0; i < x; i++) {
final Object o = GuiUtils.getChoice("Remove from game", graveList.toArray()); final Object o = GuiUtils.chooseOne("Remove from game", graveList.toArray());
if (o == null) { if (o == null) {
break; break;
} }
@@ -553,7 +553,7 @@ public class CardFactoryInstants {
} }
for (int i = 0; (i < 3) && !choices.isEmpty(); i++) { for (int i = 0; (i < 3) && !choices.isEmpty(); i++) {
final Object o = GuiUtils.getChoice(this.prompt[i], choices.toArray()); final Object o = GuiUtils.chooseOne(this.prompt[i], choices.toArray());
final Card c1 = (Card) o; final Card c1 = (Card) o;
if (i == 0) { if (i == 0) {
Singletons.getModel().getGameAction().moveToHand(c1); Singletons.getModel().getGameAction().moveToHand(c1);
@@ -640,12 +640,12 @@ public class CardFactoryInstants {
@Override @Override
public void resolve() { public void resolve() {
final String[] choices = new String[] { "Artifact", "Creature", "Land" }; final String[] choices = new String[] { "Artifact", "Creature", "Land" };
final Object o = GuiUtils.getChoice("Select permanent type", choices); final Object o = GuiUtils.chooseOne("Select permanent type", choices);
final String cardType = (String) o; final String cardType = (String) o;
final CardList list = this.getTargetPlayer().getCardsIn(Zone.Battlefield).getType(cardType); final CardList list = this.getTargetPlayer().getCardsIn(Zone.Battlefield).getType(cardType);
final String[] tapOrUntap = new String[] { "Tap", "Untap" }; final String[] tapOrUntap = new String[] { "Tap", "Untap" };
final Object z = GuiUtils.getChoice("Tap or Untap?", tapOrUntap); final Object z = GuiUtils.chooseOne("Tap or Untap?", tapOrUntap);
final boolean tap = (z.equals("Tap")) ? true : false; final boolean tap = (z.equals("Tap")) ? true : false;
for (final Card c : list) { for (final Card c : list) {

View File

@@ -606,7 +606,7 @@ class CardFactoryLands {
for (int j = 0; j <= num[0]; j++) { for (int j = 0; j <= num[0]; j++) {
choices[j] = "" + j; choices[j] = "" + j;
} }
final String answer = (GuiUtils.getChoiceOptional("Storage counters to remove", choices)); final String answer = (GuiUtils.chooseOneOrNone("Storage counters to remove", choices));
if (answer == null) { if (answer == null) {
this.stop(); this.stop();
return; return;
@@ -616,7 +616,7 @@ class CardFactoryLands {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append("Number of ").append(primary).append(" to add"); sb.append("Number of ").append(primary).append(" to add");
final String splitNum = (GuiUtils.getChoiceOptional(sb.toString(), choices)); final String splitNum = (GuiUtils.chooseOneOrNone(sb.toString(), choices));
if (splitNum == null) { if (splitNum == null) {
this.stop(); this.stop();
return; return;

View File

@@ -93,7 +93,7 @@ public class CardFactoryPlaneswalkers {
final int convertedManaTopCard = CardUtil.getConvertedManaCost(topCard.getManaCost()); final int convertedManaTopCard = CardUtil.getConvertedManaCost(topCard.getManaCost());
final CardList showTop = new CardList(); final CardList showTop = new CardList();
showTop.add(topCard); showTop.add(topCard);
GuiUtils.getChoiceOptional("Revealed top card: ", showTop.toArray()); GuiUtils.chooseOneOrNone("Revealed top card: ", showTop.toArray());
// now, move it to player's hand // now, move it to player's hand
Singletons.getModel().getGameAction().moveToHand(topCard); Singletons.getModel().getGameAction().moveToHand(topCard);

View File

@@ -285,12 +285,12 @@ public class CardFactorySorceries {
final StringBuilder msg = new StringBuilder(); final StringBuilder msg = new StringBuilder();
msg.append("Revealing top ").append(count).append(" cards of library: "); msg.append("Revealing top ").append(count).append(" cards of library: ");
GuiUtils.getChoice(msg.toString(), cards.toArray()); GuiUtils.chooseOne(msg.toString(), cards.toArray());
// Human chooses // Human chooses
if (card.getController().isComputer()) { if (card.getController().isComputer()) {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
if (!stop) { if (!stop) {
choice = GuiUtils.getChoiceOptional("Choose cards to put into the first pile: ", choice = GuiUtils.chooseOneOrNone("Choose cards to put into the first pile: ",
cards.toArray()); cards.toArray());
if (choice != null) { if (choice != null) {
pile1.add(choice); pile1.add(choice);
@@ -400,7 +400,7 @@ public class CardFactorySorceries {
final int numChosen = chosen.size(); final int numChosen = chosen.size();
for (int i = 0; i < numChosen; i++) { for (int i = 0; i < numChosen; i++) {
final Object check = GuiUtils.getChoiceOptional("Select spells to play in reverse order: ", final Object check = GuiUtils.chooseOneOrNone("Select spells to play in reverse order: ",
chosen.toArray()); chosen.toArray());
if (check == null) { if (check == null) {
break; break;
@@ -1369,7 +1369,7 @@ public class CardFactorySorceries {
final int num = CardFactoryUtil.getNumberOfManaSymbolsByColor("U", topCards); final int num = CardFactoryUtil.getNumberOfManaSymbolsByColor("U", topCards);
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append("Revealed cards - ").append(num).append(" U mana symbols"); sb.append("Revealed cards - ").append(num).append(" U mana symbols");
GuiUtils.getChoiceOptional(sb.toString(), topCards.toArray()); GuiUtils.chooseOneOrNone(sb.toString(), topCards.toArray());
// opponent moves this many cards to graveyard // opponent moves this many cards to graveyard
opp.mill(num); opp.mill(num);
@@ -1747,7 +1747,7 @@ public class CardFactorySorceries {
} }
}); });
final Object check = GuiUtils.getChoiceOptional("Select target creature with CMC < X", final Object check = GuiUtils.chooseOneOrNone("Select target creature with CMC < X",
grave.toArray()); grave.toArray());
if (check != null) { if (check != null) {
final Card c = (Card) check; final Card c = (Card) check;
@@ -1837,7 +1837,7 @@ public class CardFactorySorceries {
for (int i = 0; i <= card.getController().getLife(); i++) { for (int i = 0; i <= card.getController().getLife(); i++) {
choices.add("" + i); choices.add("" + i);
} }
final Object o = GuiUtils.getChoice("Choose X", choices.toArray()); final Object o = GuiUtils.chooseOne("Choose X", choices.toArray());
// everything stops here if user cancelled // everything stops here if user cancelled
if (o == null) { if (o == null) {
this.stop(); this.stop();
@@ -1927,7 +1927,7 @@ public class CardFactorySorceries {
private ArrayList<String> chooseTwo(final ArrayList<String> choices) { private ArrayList<String> chooseTwo(final ArrayList<String> choices) {
final ArrayList<String> out = new ArrayList<String>(); final ArrayList<String> out = new ArrayList<String>();
Object o = GuiUtils.getChoiceOptional("Choose Two", choices.toArray()); Object o = GuiUtils.chooseOneOrNone("Choose Two", choices.toArray());
if (o == null) { if (o == null) {
return null; return null;
} }
@@ -1935,7 +1935,7 @@ public class CardFactorySorceries {
out.add((String) o); out.add((String) o);
card.addSpellChoice((String) o); card.addSpellChoice((String) o);
choices.remove(out.get(0)); choices.remove(out.get(0));
o = GuiUtils.getChoiceOptional("Choose Two", choices.toArray()); o = GuiUtils.chooseOneOrNone("Choose Two", choices.toArray());
if (o == null) { if (o == null) {
return null; return null;
} }
@@ -2014,7 +2014,7 @@ public class CardFactorySorceries {
// Sacrifice an artifact // Sacrifice an artifact
CardList arts = p.getCardsIn(Constant.Zone.Battlefield); CardList arts = p.getCardsIn(Constant.Zone.Battlefield);
arts = arts.filter(CardListFilter.ARTIFACTS); arts = arts.filter(CardListFilter.ARTIFACTS);
final Object toSac = GuiUtils.getChoiceOptional("Sacrifice an artifact", arts.toArray()); final Object toSac = GuiUtils.chooseOneOrNone("Sacrifice an artifact", arts.toArray());
if (toSac != null) { if (toSac != null) {
final Card c = (Card) toSac; final Card c = (Card) toSac;
baseCMC = CardUtil.getConvertedManaCost(c); baseCMC = CardUtil.getConvertedManaCost(c);
@@ -2025,9 +2025,9 @@ public class CardFactorySorceries {
// Search your library for an artifact // Search your library for an artifact
final CardList lib = p.getCardsIn(Zone.Library); final CardList lib = p.getCardsIn(Zone.Library);
GuiUtils.getChoiceOptional("Looking at Library", lib.toArray()); GuiUtils.chooseOneOrNone("Looking at Library", lib.toArray());
final CardList libArts = lib.filter(CardListFilter.ARTIFACTS); final CardList libArts = lib.filter(CardListFilter.ARTIFACTS);
final Object o = GuiUtils.getChoiceOptional("Search for artifact", libArts.toArray()); final Object o = GuiUtils.chooseOneOrNone("Search for artifact", libArts.toArray());
if (o != null) { if (o != null) {
newArtifact[0] = (Card) o; newArtifact[0] = (Card) o;
} else { } else {

View File

@@ -807,7 +807,7 @@ public class CardFactoryUtil {
this.stop(); this.stop();
} }
Singletons.getControl().getControlMatch().showMessage("Select target Spell: "); Singletons.getControl().getControlMatch().showMessage("Select target Spell: ");
final Card choice = GuiUtils.getChoiceOptional("Choose a Spell", choices.toArray()); final Card choice = GuiUtils.chooseOneOrNone("Choose a Spell", choices.toArray());
if (choice != null) { if (choice != null) {
spell.setTargetCard(choice); spell.setTargetCard(choice);
this.done(); this.done();
@@ -1130,7 +1130,7 @@ public class CardFactoryUtil {
return; return;
} }
final Object o = GuiUtils.getChoiceOptional("Select a card", sameType.toArray()); final Object o = GuiUtils.chooseOneOrNone("Select a card", sameType.toArray());
if (o != null) { if (o != null) {
// ability.setTargetCard((Card)o); // ability.setTargetCard((Card)o);
@@ -1209,7 +1209,7 @@ public class CardFactoryUtil {
return; return;
} }
final Object o = GuiUtils.getChoiceOptional("Select a card", sameCost.toArray()); final Object o = GuiUtils.chooseOneOrNone("Select a card", sameCost.toArray());
if (o != null) { if (o != null) {
// ability.setTargetCard((Card)o); // ability.setTargetCard((Card)o);
@@ -1665,7 +1665,7 @@ public class CardFactoryUtil {
question.append(manacost).append(" or less from your graveyard to your hand?"); question.append(manacost).append(" or less from your graveyard to your hand?");
if (GameActionUtil.showYesNoDialog(sourceCard, question.toString())) { if (GameActionUtil.showYesNoDialog(sourceCard, question.toString())) {
final Object o = GuiUtils.getChoiceOptional("Select a card", sameCost.toArray()); final Object o = GuiUtils.chooseOneOrNone("Select a card", sameCost.toArray());
if (o != null) { if (o != null) {
final Card c1 = (Card) o; final Card c1 = (Card) o;
@@ -5146,7 +5146,7 @@ public class CardFactoryUtil {
card.clearDevoured(); card.clearDevoured();
if (card.getController().isHuman()) { if (card.getController().isHuman()) {
if (creats.size() > 0) { if (creats.size() > 0) {
final List<Card> selection = GuiUtils.getChoicesOptional( final List<Card> selection = GuiUtils.chooseNoneOrMany(
"Select creatures to sacrifice", creats.toArray()); "Select creatures to sacrifice", creats.toArray());
numCreatures[0] = selection.size(); numCreatures[0] = selection.size();

View File

@@ -328,7 +328,7 @@ public class CostExile extends CostPartWithList {
} }
final Object o = GuiUtils final Object o = GuiUtils
.getChoiceOptional("Exile from " + part.getFrom(), this.typeList.toArray()); .chooseOneOrNone("Exile from " + part.getFrom(), this.typeList.toArray());
if (o != null) { if (o != null) {
final Card c = (Card) o; final Card c = (Card) o;

View File

@@ -125,7 +125,7 @@ public class CostReveal extends CostPartWithList {
*/ */
@Override @Override
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) { public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
GuiUtils.getChoiceOptional("Revealed cards:", this.getList().toArray()); GuiUtils.chooseOneOrNone("Revealed cards:", this.getList().toArray());
} }
/* /*

View File

@@ -276,7 +276,7 @@ public class CostUtil {
for (int i = 0; i < choiceArray.length; i++) { for (int i = 0; i < choiceArray.length; i++) {
choiceArray[i] = i; choiceArray[i] = i;
} }
final Object o = GuiUtils.getChoice(card.toString() + " - Choose a Value for X", choiceArray); final Object o = GuiUtils.chooseOne(card.toString() + " - Choose a Value for X", choiceArray);
final int chosenX = (Integer) o; final int chosenX = (Integer) o;
card.setSVar("ChosenX", "Number$" + Integer.toString(chosenX)); card.setSVar("ChosenX", "Number$" + Integer.toString(chosenX));
@@ -302,7 +302,7 @@ public class CostUtil {
for (int i = 0; i < choiceArray.length; i++) { for (int i = 0; i < choiceArray.length; i++) {
choiceArray[i] = i; choiceArray[i] = i;
} }
final Object o = GuiUtils.getChoice(card.toString() + " - Choose a Value for Y", choiceArray); final Object o = GuiUtils.chooseOne(card.toString() + " - Choose a Value for Y", choiceArray);
final int chosenY = (Integer) o; final int chosenY = (Integer) o;
card.setSVar("ChosenY", "Number$" + Integer.toString(chosenY)); card.setSVar("ChosenY", "Number$" + Integer.toString(chosenY));

View File

@@ -452,7 +452,7 @@ public class ManaPool {
Object o; Object o;
if (this.owner.isHuman()) { if (this.owner.isHuman()) {
o = GuiUtils.getChoiceOptional("Pay Mana from Mana Pool", alChoice.toArray()); o = GuiUtils.chooseOneOrNone("Pay Mana from Mana Pool", alChoice.toArray());
} else { } else {
o = alChoice.get(0); // owner is computer o = alChoice.get(0); // owner is computer
} }

View File

@@ -94,7 +94,7 @@ public class ReplacementHandler {
if (possibleReplacers.size() > 1) { if (possibleReplacers.size() > 1) {
if (decider.isHuman()) { if (decider.isHuman()) {
chosenRE = (ReplacementEffect) GuiUtils.getChoice("Choose which replacement effect to apply.", chosenRE = (ReplacementEffect) GuiUtils.chooseOne("Choose which replacement effect to apply.",
possibleReplacers.toArray()); possibleReplacers.toArray());
} else { } else {
// AI logic for choosing which replacement effect to apply // AI logic for choosing which replacement effect to apply

View File

@@ -417,7 +417,7 @@ public class TargetSelection {
// is there a more elegant way of doing this? // is there a more elegant way of doing this?
choicesWithDone.add(dummy); choicesWithDone.add(dummy);
} }
final Object check = GuiUtils.getChoiceOptional(message, choicesWithDone.toArray()); final Object check = GuiUtils.chooseOneOrNone(message, choicesWithDone.toArray());
if (check != null) { if (check != null) {
final Card c = (Card) check; final Card c = (Card) check;
if (c.equals(dummy)) { if (c.equals(dummy)) {
@@ -460,7 +460,7 @@ public class TargetSelection {
if (choices.length == 0) { if (choices.length == 0) {
select.setCancel(true); select.setCancel(true);
} else { } else {
final String madeChoice = GuiUtils.getChoiceOptional(message, choices); final String madeChoice = GuiUtils.chooseOneOrNone(message, choices);
if (madeChoice != null) { if (madeChoice != null) {
tgt.addTarget(map.get(madeChoice)); tgt.addTarget(map.get(madeChoice));

View File

@@ -13,6 +13,8 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import org.apache.commons.lang3.ArrayUtils;
import forge.CardList; import forge.CardList;
import forge.Constant; import forge.Constant;
import forge.PlayerType; import forge.PlayerType;
@@ -26,6 +28,7 @@ import forge.game.GameNew;
import forge.game.GameType; import forge.game.GameType;
import forge.properties.ForgePreferences.FPref; import forge.properties.ForgePreferences.FPref;
import forge.quest.data.QuestEvent; import forge.quest.data.QuestEvent;
import forge.quest.data.QuestEventManager;
import forge.util.IStorage; import forge.util.IStorage;
import forge.view.home.ViewConstructed; import forge.view.home.ViewConstructed;
@@ -330,17 +333,17 @@ public class ControlConstructed {
private String[] getEventNames() { private String[] getEventNames() {
final List<String> eventNames = new ArrayList<String>(); final List<String> eventNames = new ArrayList<String>();
eventNames.clear(); final QuestEventManager qm = Singletons.getModel().getQuestEventManager();
for (final QuestEvent e : Singletons.getModel().getQuestEventManager().getAllChallenges()) { for (final QuestEvent e : qm.getAllChallenges()) {
eventNames.add(e.getEventDeck().getName()); eventNames.add(e.getEventDeck().getName());
} }
for (final QuestEvent e : Singletons.getModel().getQuestEventManager().getAllDuels()) { for (final QuestEvent e : qm.getAllDuels()) {
eventNames.add(e.getEventDeck().getName()); eventNames.add(e.getEventDeck().getName());
} }
return oa2sa(eventNames.toArray()); return eventNames.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
} }
/** /**

View File

@@ -161,7 +161,7 @@ public class ControlDraft {
draftTypes.add("Custom"); draftTypes.add("Custom");
final String prompt = "Choose Draft Format:"; final String prompt = "Choose Draft Format:";
final Object o = GuiUtils.getChoice(prompt, draftTypes.toArray()); final Object o = GuiUtils.chooseOne(prompt, draftTypes.toArray());
if (o.toString().equals(draftTypes.get(0))) { if (o.toString().equals(draftTypes.get(0))) {
draft.showGui(new BoosterDraft(CardPoolLimitation.Full)); draft.showGui(new BoosterDraft(CardPoolLimitation.Full));

View File

@@ -151,7 +151,7 @@ public class ControlSealed {
sealedTypes.add("Custom"); sealedTypes.add("Custom");
final String prompt = "Choose Sealed Deck Format:"; final String prompt = "Choose Sealed Deck Format:";
final Object o = GuiUtils.getChoice(prompt, sealedTypes.toArray()); final Object o = GuiUtils.chooseOne(prompt, sealedTypes.toArray());
SealedDeck sd = null; SealedDeck sd = null;

View File

@@ -183,7 +183,7 @@ public class InputPayManaCostUtil {
for (final AbilityMana am : abilities) { for (final AbilityMana am : abilities) {
ability.put(am.toString(), am); ability.put(am.toString(), am);
} }
chosen = (AbilityMana) GuiUtils.getChoice("Choose mana ability", abilities.toArray()); chosen = GuiUtils.chooseOne("Choose mana ability", abilities);
} }
// save off color needed for use by any mana and reflected mana // save off color needed for use by any mana and reflected mana

View File

@@ -261,7 +261,7 @@ public class ControlField {
final ArrayList<Card> choices2 = new ArrayList<Card>(); final ArrayList<Card> choices2 = new ArrayList<Card>();
if (choices.isEmpty()) { if (choices.isEmpty()) {
GuiUtils.getChoiceOptional(this.title, new String[] { "no cards" }); GuiUtils.chooseOneOrNone(this.title, new String[] { "no cards" });
} else { } else {
for (int i = 0; i < choices.size(); i++) { for (int i = 0; i < choices.size(); i++) {
final Card crd = choices.get(i); final Card crd = choices.get(i);
@@ -276,7 +276,7 @@ public class ControlField {
} }
} }
// System.out.println("Face down cards replaced: "+choices2); // System.out.println("Face down cards replaced: "+choices2);
final Card choice = (Card) GuiUtils.getChoiceOptional(this.title, choices2.toArray()); final Card choice = (Card) GuiUtils.chooseOneOrNone(this.title, choices2.toArray());
if (choice != null) { if (choice != null) {
this.doAction(choice); this.doAction(choice);
/* /*

View File

@@ -103,7 +103,7 @@ public class ControlWinLose {
Constant.Runtime.COMPUTER_DECK[0] = cDeck; Constant.Runtime.COMPUTER_DECK[0] = cDeck;
List<Card> o = GuiUtils.getChoicesOptional("Select cards to add to your deck", compAntes.toArray()); List<Card> o = GuiUtils.chooseNoneOrMany("Select cards to add to your deck", compAntes.toArray());
if (null != o) { if (null != o) {
for (Card c : o) { for (Card c : o) {
hDeck.getMain().add(c); hDeck.getMain().add(c);

View File

@@ -93,7 +93,7 @@ public final class BoosterDraft implements IBoosterDraft {
case Block: // Draft from cards by block or set case Block: // Draft from cards by block or set
final Object o = GuiUtils.getChoice("Choose Block", UtilFunctions.iteratorToArray(Singletons.getModel().getBlocks().iterator(), new CardBlock[]{})); final Object o = GuiUtils.chooseOne("Choose Block", UtilFunctions.iteratorToArray(Singletons.getModel().getBlocks().iterator(), new CardBlock[]{}));
final CardBlock block = (CardBlock) o; final CardBlock block = (CardBlock) o;
final CardEdition[] cardSets = block.getSets(); final CardEdition[] cardSets = block.getSets();
@@ -119,7 +119,7 @@ public final class BoosterDraft implements IBoosterDraft {
} }
if (sets.length > 1) { if (sets.length > 1) {
final Object p = GuiUtils.getChoice("Choose Set Combination", setCombos.toArray()); final Object p = GuiUtils.chooseOne("Choose Set Combination", setCombos.toArray());
final String[] pp = p.toString().split("/"); final String[] pp = p.toString().split("/");
for (int i = 0; i < nPacks; i++) { for (int i = 0; i < nPacks; i++) {
this.product.add(new UnOpenedProduct(Singletons.getModel().getBoosters().get(pp[i]))); this.product.add(new UnOpenedProduct(Singletons.getModel().getBoosters().get(pp[i])));
@@ -142,7 +142,7 @@ public final class BoosterDraft implements IBoosterDraft {
JOptionPane JOptionPane
.showMessageDialog(null, "No custom draft files found.", "", JOptionPane.INFORMATION_MESSAGE); .showMessageDialog(null, "No custom draft files found.", "", JOptionPane.INFORMATION_MESSAGE);
} else { } else {
final CustomLimited draft = (CustomLimited) GuiUtils.getChoice("Choose Custom Draft", final CustomLimited draft = (CustomLimited) GuiUtils.chooseOne("Choose Custom Draft",
myDrafts.toArray()); myDrafts.toArray());
this.setupCustomDraft(draft); this.setupCustomDraft(draft);
} }

View File

@@ -79,7 +79,7 @@ public class SealedDeck {
this.getLandSetCode()[0] = CardDb.instance().getCard("Plains").getEdition(); this.getLandSetCode()[0] = CardDb.instance().getCard("Plains").getEdition();
} else if (sealedType.equals("Block")) { } else if (sealedType.equals("Block")) {
final Object o = GuiUtils.getChoice("Choose Block", UtilFunctions.iteratorToArray(Singletons.getModel().getBlocks().iterator(), new CardBlock[]{})); final Object o = GuiUtils.chooseOne("Choose Block", UtilFunctions.iteratorToArray(Singletons.getModel().getBlocks().iterator(), new CardBlock[]{}));
final CardBlock block = (CardBlock) o; final CardBlock block = (CardBlock) o;
final CardEdition[] cardSets = block.getSets(); final CardEdition[] cardSets = block.getSets();
@@ -102,7 +102,7 @@ public class SealedDeck {
} }
if (sets.length > 1) { if (sets.length > 1) {
final Object p = GuiUtils.getChoice("Choose Set Combination", setCombos.toArray()); final Object p = GuiUtils.chooseOne("Choose Set Combination", setCombos.toArray());
final String[] pp = p.toString().split("/"); final String[] pp = p.toString().split("/");
for (int i = 0; i < nPacks; i++) { for (int i = 0; i < nPacks; i++) {
@@ -147,7 +147,7 @@ public class SealedDeck {
JOptionPane.showMessageDialog(null, "No custom sealed files found.", "", JOptionPane.showMessageDialog(null, "No custom sealed files found.", "",
JOptionPane.INFORMATION_MESSAGE); JOptionPane.INFORMATION_MESSAGE);
} else { } else {
final CustomLimited draft = (CustomLimited) GuiUtils.getChoice("Choose Custom Sealed Pool", final CustomLimited draft = (CustomLimited) GuiUtils.chooseOne("Choose Custom Sealed Pool",
customs.toArray()); customs.toArray());
final BoosterGenerator bpCustom = new BoosterGenerator(draft.getCardPool()); final BoosterGenerator bpCustom = new BoosterGenerator(draft.getCardPool());

View File

@@ -249,7 +249,7 @@ public final class GuiUtils {
* getChoices. * getChoices.
* @see #getChoices(String, int, int, Object...) * @see #getChoices(String, int, int, Object...)
*/ */
public static <T> T getChoiceOptional(final String message, final T... choices) { public static <T> T chooseOneOrNone(final String message, final T... choices) {
if ((choices == null) || (choices.length == 0)) { if ((choices == null) || (choices.length == 0)) {
return null; return null;
} }
@@ -271,12 +271,18 @@ public final class GuiUtils {
* a T object. * a T object.
* @return a T object. * @return a T object.
*/ */
public static <T> T getChoice(final String message, final T... choices) { public static <T> T chooseOne(final String message, final T... choices) {
final List<T> choice = GuiUtils.getChoices(message, 1, 1, choices); final List<T> choice = GuiUtils.getChoices(message, 1, 1, choices);
assert choice.size() == 1; assert choice.size() == 1;
return choice.get(0); return choice.get(0);
} // getChoice() } // getChoice()
public static <T> T chooseOne(final String message, final List<T> choices) {
final List<T> choice = GuiUtils.getChoices(message, 1, 1, choices);
assert choice.size() == 1;
return choice.get(0);
}
// returned Object will never be null // returned Object will never be null
/** /**
* <p> * <p>
@@ -291,7 +297,7 @@ public final class GuiUtils {
* a T object. * a T object.
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
public static <T> List<T> getChoicesOptional(final String message, final T... choices) { public static <T> List<T> chooseNoneOrMany(final String message, final T... choices) {
return GuiUtils.getChoices(message, 0, choices.length, choices); return GuiUtils.getChoices(message, 0, choices.length, choices);
} // getChoice() } // getChoice()
@@ -309,7 +315,7 @@ public final class GuiUtils {
* a T object. * a T object.
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
public static <T> List<T> getChoices(final String message, final T... choices) { public static <T> List<T> chooseOneOrMany(final String message, final T... choices) {
return GuiUtils.getChoices(message, 1, choices.length, choices); return GuiUtils.getChoices(message, 1, choices.length, choices);
} // getChoice() } // getChoice()
@@ -331,8 +337,18 @@ public final class GuiUtils {
* a T object. * a T object.
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
public static <T> List<T> getChoices(final String message, final int min, final int max, final T... choices) { private static <T> List<T> getChoices(final String message, final int min, final int max, final T... choices) {
final ListChooser<T> c = new ListChooser<T>(message, min, max, choices); final ListChooser<T> c = new ListChooser<T>(message, min, max, choices);
return getChoices(c);
}
private static <T> List<T> getChoices(final String message, final int min, final int max, final List<T> choices) {
final ListChooser<T> c = new ListChooser<T>(message, min, max, choices);
return getChoices(c);
}
private static <T> List<T> getChoices(final ListChooser<T> c)
{
final JList list = c.getJList(); final JList list = c.getJList();
list.addListSelectionListener(new ListSelectionListener() { list.addListSelectionListener(new ListSelectionListener() {
@Override @Override

View File

@@ -78,8 +78,8 @@ public class ListChooser<T> {
// initialized before; listeners may be added to it // initialized before; listeners may be added to it
private JList jList; private JList jList;
// Temporarily stored for event handlers during show // Temporarily stored for event handlers during show
private JDialog d; private JDialog dialog;
private JOptionPane p; private JOptionPane optionPane;
private Action ok, cancel; private Action ok, cancel;
/** /**
@@ -304,23 +304,12 @@ public class ListChooser<T> {
this.jList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); this.jList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
} }
this.p = new JOptionPane(new Object[] { message, new JScrollPane(this.jList) }, JOptionPane.QUESTION_MESSAGE, this.optionPane = new JOptionPane(new Object[] { message, new JScrollPane(this.jList) }, JOptionPane.QUESTION_MESSAGE,
JOptionPane.DEFAULT_OPTION, null, options, options[0]); JOptionPane.DEFAULT_OPTION, null, options, options[0]);
this.jList.getSelectionModel().addListSelectionListener(new SelListener()); this.jList.getSelectionModel().addListSelectionListener(new SelListener());
this.jList.addMouseListener(new DblListener()); this.jList.addMouseListener(new DblListener());
} }
/**
* <p>
* getChoices.
* </p>
*
* @return a {@link java.util.List} object.
*/
public List<T> getChoices() {
return this.list;
}
/** /**
* Returns the JList used in the list chooser. this is useful for * Returns the JList used in the list chooser. this is useful for
* registering listeners before showing the dialog. * registering listeners before showing the dialog.
@@ -348,14 +337,14 @@ public class ListChooser<T> {
} }
Integer value; Integer value;
do { do {
this.d = this.p.createDialog(this.p.getParent(), this.title); this.dialog = this.optionPane.createDialog(this.optionPane.getParent(), this.title);
if (this.minChoices != 0) { if (this.minChoices != 0) {
this.d.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); this.dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
} }
this.jList.setSelectedIndex(index0); this.jList.setSelectedIndex(index0);
this.d.addWindowFocusListener(new WindowFocusListener() { this.dialog.addWindowFocusListener(new WindowFocusListener() {
@Override @Override
public void windowGainedFocus(final WindowEvent e) { public void windowGainedFocus(final WindowEvent e) {
ListChooser.this.jList.grabFocus(); ListChooser.this.jList.grabFocus();
@@ -365,9 +354,9 @@ public class ListChooser<T> {
public void windowLostFocus(final WindowEvent e) { public void windowLostFocus(final WindowEvent e) {
} }
}); });
this.d.setVisible(true); this.dialog.setVisible(true);
this.d.dispose(); this.dialog.dispose();
value = (Integer) this.p.getValue(); value = (Integer) this.optionPane.getValue();
if ((value == null) || (value != JOptionPane.OK_OPTION)) { if ((value == null) || (value != JOptionPane.OK_OPTION)) {
this.jList.clearSelection(); this.jList.clearSelection();
// can't stop closing by ESC, so repeat if cancelled // can't stop closing by ESC, so repeat if cancelled
@@ -390,7 +379,7 @@ public class ListChooser<T> {
if (!this.called) { if (!this.called) {
throw new IllegalStateException("not yet shown"); throw new IllegalStateException("not yet shown");
} }
return (Integer) this.p.getValue() == JOptionPane.OK_OPTION; return (Integer) this.optionPane.getValue() == JOptionPane.OK_OPTION;
} }
/** /**
@@ -398,22 +387,11 @@ public class ListChooser<T> {
* *
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
public List<Integer> getSelectedIndices() { public int[] getSelectedIndices() {
if (!this.called) { if (!this.called) {
throw new IllegalStateException("not yet shown"); throw new IllegalStateException("not yet shown");
} }
final int[] indices = this.jList.getSelectedIndices(); return this.jList.getSelectedIndices();
return new AbstractList<Integer>() {
@Override
public int size() {
return indices.length;
}
@Override
public Integer get(final int index) {
return indices[index];
}
};
} }
/** /**
@@ -473,7 +451,7 @@ public class ListChooser<T> {
*/ */
private void commit() { private void commit() {
if (this.ok.isEnabled()) { if (this.ok.isEnabled()) {
this.p.setValue(JOptionPane.OK_OPTION); this.optionPane.setValue(JOptionPane.OK_OPTION);
} }
} }
@@ -504,7 +482,7 @@ public class ListChooser<T> {
@Override @Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
ListChooser.this.p.setValue(this.value); ListChooser.this.optionPane.setValue(this.value);
} }
} }

View File

@@ -105,7 +105,7 @@ public class MenuBase<T extends DeckBase> extends JMenuBar {
return null; return null;
} }
final Object o = GuiUtils.getChoiceOptional("Open Deck", choices.toArray()); final Object o = GuiUtils.chooseOneOrNone("Open Deck", choices.toArray());
return o == null ? null : o.toString(); return o == null ? null : o.toString();
} }

View File

@@ -187,7 +187,7 @@ public enum CSubmenuDraft implements ICSubmenu {
draftTypes.add("Custom"); draftTypes.add("Custom");
final String prompt = "Choose Draft Format:"; final String prompt = "Choose Draft Format:";
final Object o = GuiUtils.getChoice(prompt, draftTypes.toArray()); final Object o = GuiUtils.chooseOne(prompt, draftTypes.toArray());
if (o.toString().equals(draftTypes.get(0))) { if (o.toString().equals(draftTypes.get(0))) {
draft.showGui(new BoosterDraft(CardPoolLimitation.Full)); draft.showGui(new BoosterDraft(CardPoolLimitation.Full));

View File

@@ -135,7 +135,7 @@ public enum CSubmenuSealed implements ICSubmenu {
sealedTypes.add("Custom"); sealedTypes.add("Custom");
final String prompt = "Choose Sealed Deck Format:"; final String prompt = "Choose Sealed Deck Format:";
final Object o = GuiUtils.getChoice(prompt, sealedTypes.toArray()); final Object o = GuiUtils.chooseOne(prompt, sealedTypes.toArray());
SealedDeck sd = null; SealedDeck sd = null;