diff --git a/forge-gui/src/main/java/forge/control/InputQueue.java b/forge-gui/src/main/java/forge/control/InputQueue.java index 39f5384b7d2..110b830ed0b 100644 --- a/forge-gui/src/main/java/forge/control/InputQueue.java +++ b/forge-gui/src/main/java/forge/control/InputQueue.java @@ -80,15 +80,7 @@ public class InputQueue extends Observable { return inputStack.toString(); } - public void setInputAndWait(InputSynchronized input) { - this.inputStack.push(input); - syncPoint(); - this.updateObservers(); - - input.awaitLatchRelease(); - } - - void setInput(InputSynchronized input) { + public void setInput(InputSynchronized input) { this.inputStack.push(input); syncPoint(); this.updateObservers(); diff --git a/forge-gui/src/main/java/forge/game/ability/effects/CountersProliferateEffect.java b/forge-gui/src/main/java/forge/game/ability/effects/CountersProliferateEffect.java index 6bb366b7ee0..b13fb2cae64 100644 --- a/forge-gui/src/main/java/forge/game/ability/effects/CountersProliferateEffect.java +++ b/forge-gui/src/main/java/forge/game/ability/effects/CountersProliferateEffect.java @@ -5,7 +5,6 @@ import java.util.List; import java.util.Map.Entry; import com.google.common.base.Predicate; -import forge.Singletons; import forge.ai.ComputerUtil; import forge.game.GameEntity; import forge.game.ability.SpellAbilityEffect; @@ -34,7 +33,7 @@ public class CountersProliferateEffect extends SpellAbilityEffect { if (controller.isHuman()) { InputProliferate inp = new InputProliferate(); inp.setCancelAllowed(true); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if ( inp.hasCancelled() ) return; diff --git a/forge-gui/src/main/java/forge/game/ability/effects/UntapEffect.java b/forge-gui/src/main/java/forge/game/ability/effects/UntapEffect.java index 9442ae88bd3..2f09441f6f6 100644 --- a/forge-gui/src/main/java/forge/game/ability/effects/UntapEffect.java +++ b/forge-gui/src/main/java/forge/game/ability/effects/UntapEffect.java @@ -4,7 +4,6 @@ import java.util.List; import org.apache.commons.lang3.StringUtils; -import forge.Singletons; import forge.ai.ComputerUtilCard; import forge.game.ability.AbilityUtils; import forge.game.ability.SpellAbilityEffect; @@ -83,7 +82,7 @@ public class UntapEffect extends SpellAbilityEffect { if (p.isHuman()) { InputSelectCards sc = new InputSelectCardsFromList(0, num, list); - Singletons.getControl().getInputQueue().setInputAndWait(sc); + sc.showAndWait(); if( !sc.hasCancelled() ) for( Card c : sc.getSelected() ) c.untap(); diff --git a/forge-gui/src/main/java/forge/game/card/CardFactoryUtil.java b/forge-gui/src/main/java/forge/game/card/CardFactoryUtil.java index b79c6dc347c..7e7ff1ca882 100644 --- a/forge-gui/src/main/java/forge/game/card/CardFactoryUtil.java +++ b/forge-gui/src/main/java/forge/game/card/CardFactoryUtil.java @@ -26,7 +26,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.Command; -import forge.Singletons; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCost; @@ -2859,7 +2858,7 @@ public class CardFactoryUtil { if (card.getController().isHuman()) { final InputSelectCards target = new InputSelectCardsFromList(1, 1, creats); target.setMessage("Choose target creature to haunt."); - Singletons.getControl().getInputQueue().setInputAndWait(target); + target.showAndWait(); toHaunt = target.getSelected().get(0); } else { // AI choosing what to haunt diff --git a/forge-gui/src/main/java/forge/game/cost/CostDiscard.java b/forge-gui/src/main/java/forge/game/cost/CostDiscard.java index 5e422429b1e..77b77c06650 100644 --- a/forge-gui/src/main/java/forge/game/cost/CostDiscard.java +++ b/forge-gui/src/main/java/forge/game/cost/CostDiscard.java @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.List; import com.google.common.base.Predicate; -import forge.Singletons; import forge.ai.AiController; import forge.game.Game; import forge.game.ability.AbilityUtils; @@ -221,7 +220,7 @@ public class CostDiscard extends CostPartWithList { InputSelectCards inp = new InputSelectCardsFromList(1, 1, handList); inp.setMessage("Select one of the cards with the same name to discard. Already chosen: " + discarded); inp.setCancelAllowed(true); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if (inp.hasCancelled()) { return false; } @@ -252,7 +251,7 @@ public class CostDiscard extends CostPartWithList { InputSelectCards inp = new InputSelectCardsFromList(c, c, handList); inp.setMessage("Select %d more " + getDescriptiveType() + " to discard."); inp.setCancelAllowed(true); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if (inp.hasCancelled() || inp.getSelected().size() != c) { return false; } diff --git a/forge-gui/src/main/java/forge/game/cost/CostExile.java b/forge-gui/src/main/java/forge/game/cost/CostExile.java index 0a49f62eef3..b45f5008b00 100644 --- a/forge-gui/src/main/java/forge/game/cost/CostExile.java +++ b/forge-gui/src/main/java/forge/game/cost/CostExile.java @@ -22,7 +22,6 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -import forge.Singletons; import forge.ai.ComputerUtil; import forge.game.Game; import forge.game.ability.AbilityUtils; @@ -270,7 +269,7 @@ public class CostExile extends CostPartWithList { InputSelectCards inp = new InputSelectCardsFromList(c, c, list); inp.setMessage("Exile %d card(s) from your" + from); inp.setCancelAllowed(true); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); return !inp.hasCancelled() && executePayment(ability, inp.getSelected()); } diff --git a/forge-gui/src/main/java/forge/game/cost/CostGainControl.java b/forge-gui/src/main/java/forge/game/cost/CostGainControl.java index ecbcaad6129..332cf1173f5 100644 --- a/forge-gui/src/main/java/forge/game/cost/CostGainControl.java +++ b/forge-gui/src/main/java/forge/game/cost/CostGainControl.java @@ -19,7 +19,6 @@ package forge.game.cost; import java.util.ArrayList; import java.util.List; -import forge.Singletons; import forge.game.Game; import forge.game.ability.AbilityUtils; import forge.game.card.Card; @@ -110,7 +109,7 @@ public class CostGainControl extends CostPartWithList { InputSelectCards inp = new InputSelectCardsFromList(c, c, validCards); inp.setMessage("Gain control of %d " + desc); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if (inp.hasCancelled()) { return false; } diff --git a/forge-gui/src/main/java/forge/game/cost/CostPartMana.java b/forge-gui/src/main/java/forge/game/cost/CostPartMana.java index c2a315960e4..f0810fab9e2 100644 --- a/forge-gui/src/main/java/forge/game/cost/CostPartMana.java +++ b/forge-gui/src/main/java/forge/game/cost/CostPartMana.java @@ -17,7 +17,6 @@ */ package forge.game.cost; -import forge.Singletons; import forge.ai.ComputerUtilMana; import forge.card.MagicColor; import forge.card.mana.ManaCost; @@ -135,7 +134,7 @@ public class CostPartMana extends CostPart { } if (!toPay.isPaid()) { inpPayment = new InputPayManaOfCostPayment(toPay, ability); - Singletons.getControl().getInputQueue().setInputAndWait(inpPayment); + inpPayment.showAndWait(); if (!inpPayment.isPaid()) { return handleOfferingAndConvoke(ability, true, false); } @@ -147,7 +146,7 @@ public class CostPartMana extends CostPart { if (!ability.isAnnouncing("X") && !xWasBilled) { source.setXManaCostPaid(0); inpPayment = new InputPayManaX(ability, this.getAmountOfX(), this.canXbe0()); - Singletons.getControl().getInputQueue().setInputAndWait(inpPayment); + inpPayment.showAndWait(); if (!inpPayment.isPaid()) { return false; } diff --git a/forge-gui/src/main/java/forge/game/cost/CostPutCardToLib.java b/forge-gui/src/main/java/forge/game/cost/CostPutCardToLib.java index c03ceb430cc..3d55c5d65db 100644 --- a/forge-gui/src/main/java/forge/game/cost/CostPutCardToLib.java +++ b/forge-gui/src/main/java/forge/game/cost/CostPutCardToLib.java @@ -20,7 +20,6 @@ package forge.game.cost; import java.util.ArrayList; import java.util.List; -import forge.Singletons; import forge.ai.ComputerUtil; import forge.game.Game; import forge.game.ability.AbilityUtils; @@ -238,7 +237,7 @@ public class CostPutCardToLib extends CostPartWithList { InputSelectCards inp = new InputSelectCardsFromList(c, c, list); inp.setMessage("Put %d card(s) from your " + from ); inp.setCancelAllowed(true); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); return !inp.hasCancelled() && executePayment(ability, inp.getSelected()); } diff --git a/forge-gui/src/main/java/forge/game/cost/CostPutCounter.java b/forge-gui/src/main/java/forge/game/cost/CostPutCounter.java index 0cc7a2854fc..2588d393789 100644 --- a/forge-gui/src/main/java/forge/game/cost/CostPutCounter.java +++ b/forge-gui/src/main/java/forge/game/cost/CostPutCounter.java @@ -21,7 +21,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import forge.Singletons; import forge.ai.ComputerUtilCard; import forge.game.Game; import forge.game.ability.AbilityUtils; @@ -271,8 +270,8 @@ public class CostPutCounter extends CostPartWithList { InputSelectCardToPutCounter inp = new InputSelectCardToPutCounter(c, typeList); inp.setMessage("Put %d " + getCounter().getName() + " counter on " + getDescriptiveType()); inp.setCancelAllowed(true); - Singletons.getControl().getInputQueue().setInputAndWait(inp); - + inp.showAndWait(); + if(inp.hasCancelled()) return false; diff --git a/forge-gui/src/main/java/forge/game/cost/CostRemoveAnyCounter.java b/forge-gui/src/main/java/forge/game/cost/CostRemoveAnyCounter.java index 5d4bf8ef79e..60ac75db7e0 100644 --- a/forge-gui/src/main/java/forge/game/cost/CostRemoveAnyCounter.java +++ b/forge-gui/src/main/java/forge/game/cost/CostRemoveAnyCounter.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.Map; import com.google.common.base.Predicate; -import forge.Singletons; import forge.ai.ComputerUtil; import forge.game.Game; import forge.game.ability.AbilityUtils; @@ -133,7 +132,7 @@ public class CostRemoveAnyCounter extends CostPartWithList { InputSelectCards inp = new InputSelectCardsFromList(1, 1, list); inp.setMessage("Select " + this.getDescriptiveType() + " to remove a counter"); inp.setCancelAllowed(false); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); Card selected = inp.getSelected().get(0); final Map tgtCounters = selected.getCounters(); final ArrayList typeChoices = new ArrayList(); diff --git a/forge-gui/src/main/java/forge/game/cost/CostRemoveCounter.java b/forge-gui/src/main/java/forge/game/cost/CostRemoveCounter.java index 2e570384d4d..3143b28871a 100644 --- a/forge-gui/src/main/java/forge/game/cost/CostRemoveCounter.java +++ b/forge-gui/src/main/java/forge/game/cost/CostRemoveCounter.java @@ -24,7 +24,6 @@ import java.util.Map; import com.google.common.collect.Lists; -import forge.Singletons; import forge.game.Game; import forge.game.ability.AbilityUtils; import forge.game.card.Card; @@ -164,7 +163,7 @@ public class CostRemoveCounter extends CostPartWithList { final InputSelectCardToRemoveCounter inp = new InputSelectCardToRemoveCounter(cntRemoved, getCounter(), validCards); inp.setMessage("Remove %d " + getCounter().getName() + " counters from " + getDescriptiveType()); inp.setCancelAllowed(true); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if(inp.hasCancelled()) return false; diff --git a/forge-gui/src/main/java/forge/game/cost/CostReturn.java b/forge-gui/src/main/java/forge/game/cost/CostReturn.java index 19bb7cf8a61..986f7b4312b 100644 --- a/forge-gui/src/main/java/forge/game/cost/CostReturn.java +++ b/forge-gui/src/main/java/forge/game/cost/CostReturn.java @@ -20,7 +20,6 @@ package forge.game.cost; import java.util.ArrayList; import java.util.List; -import forge.Singletons; import forge.ai.ComputerUtil; import forge.game.Game; import forge.game.ability.AbilityUtils; @@ -147,7 +146,7 @@ public class CostReturn extends CostPartWithList { InputSelectCards inp = new InputSelectCardsFromList(c, c, validCards); inp.setMessage("Return %d " + this.getType() + " " + this.getType() + " card(s) to hand"); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if (inp.hasCancelled()) return false; diff --git a/forge-gui/src/main/java/forge/game/cost/CostReveal.java b/forge-gui/src/main/java/forge/game/cost/CostReveal.java index b3e48c7c492..d23fafefc40 100644 --- a/forge-gui/src/main/java/forge/game/cost/CostReveal.java +++ b/forge-gui/src/main/java/forge/game/cost/CostReveal.java @@ -23,7 +23,6 @@ import java.util.List; import com.google.common.base.Predicate; import com.google.common.collect.Lists; -import forge.Singletons; import forge.ai.AiController; import forge.game.Game; import forge.game.ability.AbilityUtils; @@ -195,7 +194,7 @@ public class CostReveal extends CostPartWithList { InputSelectCards inp = new InputSelectCardsFromList(1, 1, handList); inp.setMessage("Select one of cards to reveal. Already chosen:" + revealed); inp.setCancelAllowed(true); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if (inp.hasCancelled()) return false; final Card first = inp.getSelected().get(0); @@ -222,7 +221,7 @@ public class CostReveal extends CostPartWithList { if ( num == 0 ) return true; InputSelectCards inp = new InputSelectCardsFromList(num, num, handList); inp.setMessage("Select %d more " + getDescriptiveType() + " card(s) to reveal."); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if ( inp.hasCancelled() ) return false; diff --git a/forge-gui/src/main/java/forge/game/cost/CostSacrifice.java b/forge-gui/src/main/java/forge/game/cost/CostSacrifice.java index 953da04ce51..dbc6f618719 100644 --- a/forge-gui/src/main/java/forge/game/cost/CostSacrifice.java +++ b/forge-gui/src/main/java/forge/game/cost/CostSacrifice.java @@ -20,7 +20,6 @@ package forge.game.cost; import java.util.ArrayList; import java.util.List; -import forge.Singletons; import forge.ai.ComputerUtil; import forge.game.Game; import forge.game.ability.AbilityUtils; @@ -166,7 +165,7 @@ public class CostSacrifice extends CostPartWithList { InputSelectCards inp = new InputSelectCardsFromList(c, c, list); inp.setMessage("Select a " + this.getDescriptiveType() + " to sacrifice (%d left)"); inp.setCancelAllowed(true); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if ( inp.hasCancelled() ) return false; diff --git a/forge-gui/src/main/java/forge/game/cost/CostTapType.java b/forge-gui/src/main/java/forge/game/cost/CostTapType.java index da61b3b0d04..c60d15cde91 100644 --- a/forge-gui/src/main/java/forge/game/cost/CostTapType.java +++ b/forge-gui/src/main/java/forge/game/cost/CostTapType.java @@ -22,7 +22,6 @@ import java.util.List; import com.google.common.base.Predicate; -import forge.Singletons; import forge.ai.ComputerUtil; import forge.game.Game; import forge.game.ability.AbilityUtils; @@ -225,7 +224,7 @@ public class CostTapType extends CostPartWithList { InputSelectCards inp = new InputSelectCardsFromList(1, 1, typeList); inp.setMessage("Select one of the cards to tap. Already chosen: " + tapped); inp.setCancelAllowed(true); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if (inp.hasCancelled()) return false; final Card first = inp.getSelected().get(0); @@ -248,7 +247,7 @@ public class CostTapType extends CostPartWithList { inp.setMessage("Select a card to tap."); inp.setUnselectAllowed(true); inp.setCancelAllowed(true); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if (inp.hasCancelled() || CardLists.getTotalPower(inp.getSelected()) < i) { return false; @@ -259,7 +258,7 @@ public class CostTapType extends CostPartWithList { InputSelectCards inp = new InputSelectCardsFromList(c, c, typeList); inp.setMessage("Select a " + getDescriptiveType() + " to tap (%d left)"); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if ( inp.hasCancelled() ) return false; diff --git a/forge-gui/src/main/java/forge/game/cost/CostUntapType.java b/forge-gui/src/main/java/forge/game/cost/CostUntapType.java index cbd3ecd4840..ff487eccbaf 100644 --- a/forge-gui/src/main/java/forge/game/cost/CostUntapType.java +++ b/forge-gui/src/main/java/forge/game/cost/CostUntapType.java @@ -18,7 +18,6 @@ package forge.game.cost; import java.util.List; -import forge.Singletons; import forge.ai.ComputerUtil; import forge.game.Game; import forge.game.ability.AbilityUtils; @@ -153,7 +152,7 @@ public class CostUntapType extends CostPartWithList { } InputSelectCards inp = new InputSelectCardsFromList(c, c, typeList); inp.setMessage("Select a " + getDescriptiveType() + " to untap (%d left)"); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if( inp.hasCancelled() || inp.getSelected().size() != c ) return false; diff --git a/forge-gui/src/main/java/forge/game/phase/Untap.java b/forge-gui/src/main/java/forge/game/phase/Untap.java index 77238b2785a..ad0c9e21190 100644 --- a/forge-gui/src/main/java/forge/game/phase/Untap.java +++ b/forge-gui/src/main/java/forge/game/phase/Untap.java @@ -23,7 +23,6 @@ import java.util.List; import com.google.common.base.Predicate; import com.google.common.base.Predicates; -import forge.Singletons; import forge.ai.ComputerUtilCard; import forge.game.Game; import forge.game.GameEntity; @@ -216,7 +215,7 @@ public class Untap extends Phase { } else { final InputSelectCards target = new InputSelectCardsFromList(1,1, landList); target.setMessage("Select one tapped land to untap"); - Singletons.getControl().getInputQueue().setInputAndWait(target); + target.showAndWait(); if( !target.hasCancelled() && !target.getSelected().isEmpty()) toUntap = target.getSelected().get(0); } @@ -233,7 +232,7 @@ public class Untap extends Phase { } else { final InputSelectCards target = new InputSelectCardsFromList(1,1, artList); target.setMessage("Select one tapped artifact to untap"); - Singletons.getControl().getInputQueue().setInputAndWait(target); + target.showAndWait(); if( !target.hasCancelled() && !target.getSelected().isEmpty()) target.getSelected().get(0).untap(); } @@ -247,7 +246,7 @@ public class Untap extends Phase { } else { final InputSelectCards target = new InputSelectCardsFromList(1, 1, creatures); target.setMessage("Select one creature to untap"); - Singletons.getControl().getInputQueue().setInputAndWait(target); + target.showAndWait(); if( !target.hasCancelled() && !target.getSelected().isEmpty()) target.getSelected().get(0).untap(); } diff --git a/forge-gui/src/main/java/forge/game/player/HumanPlay.java b/forge-gui/src/main/java/forge/game/player/HumanPlay.java index 492292578c6..560bf15ff94 100644 --- a/forge-gui/src/main/java/forge/game/player/HumanPlay.java +++ b/forge-gui/src/main/java/forge/game/player/HumanPlay.java @@ -9,7 +9,6 @@ import org.apache.commons.lang3.StringUtils; import com.google.common.base.Predicate; import forge.FThreads; -import forge.Singletons; import forge.card.mana.ManaCost; import forge.game.GameActionUtil; import forge.game.Game; @@ -164,7 +163,7 @@ public class HumanPlay { if (!isPaid) { InputPayMana inputPay = new InputPayManaSimple(p.getGame(), sa, manaCost); - Singletons.getControl().getInputQueue().setInputAndWait(inputPay); + inputPay.showAndWait(); isPaid = inputPay.isPaid(); } return isPaid; @@ -440,7 +439,7 @@ public class HumanPlay { InputSelectCards inp = new InputSelectCardsFromList(1, 1, list); inp.setMessage("Select a card to add a counter to"); inp.setCancelAllowed(true); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if (inp.hasCancelled()) { continue; } @@ -492,7 +491,7 @@ public class HumanPlay { InputSelectCards inp = new InputSelectCardsFromList(1, 1, list); inp.setMessage("Select a card to remove a counter"); inp.setCancelAllowed(true); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if (inp.hasCancelled()) { continue; } @@ -680,7 +679,7 @@ public class HumanPlay { prompt = source + "\n" + promptCurrent; } InputPayMana toSet = new InputPayManaExecuteCommands(source, p, prompt, cost.getCostMana().getManaToPay()); - Singletons.getControl().getInputQueue().setInputAndWait(toSet); + toSet.showAndWait(); return toSet.isPaid(); } @@ -691,7 +690,7 @@ public class HumanPlay { inp.setMessage("Select %d " + cpl.getDescriptiveType() + " card(s) to " + actionName); inp.setCancelAllowed(true); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); if (inp.hasCancelled() || inp.getSelected().size() != amount) { return false; } diff --git a/forge-gui/src/main/java/forge/game/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/game/player/PlayerControllerHuman.java index eeaca4dc354..f42da842345 100644 --- a/forge-gui/src/main/java/forge/game/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/game/player/PlayerControllerHuman.java @@ -317,7 +317,7 @@ public class PlayerControllerHuman extends PlayerController { InputSelectCards inp = new InputSelectCardsFromList(min == 0 ? 1 : min, max, valid); inp.setMessage(outerMessage); inp.setCancelAllowed(min == 0); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); return inp.hasCancelled() ? Lists.newArrayList() : inp.getSelected(); } @@ -364,7 +364,7 @@ public class PlayerControllerHuman extends PlayerController { InputSelectCardsFromList input = new InputSelectCardsFromList(isOptional ? 0 : 1, 1, options); input.setCancelAllowed(isOptional); input.setMessage(title); - Singletons.getControl().getInputQueue().setInputAndWait(input); + input.showAndWait(); return Iterables.getFirst(input.getSelected(), null); } @@ -441,7 +441,7 @@ public class PlayerControllerHuman extends PlayerController { @Override public boolean getWillPlayOnFirstTurn(boolean isFirstGame) { InputPlayOrDraw inp = new InputPlayOrDraw(player, isFirstGame); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); return inp.isPlayingFirst(); } @@ -532,7 +532,7 @@ public class PlayerControllerHuman extends PlayerController { InputSelectCards inp = new InputSelectCardsFromList(min, max, valid); inp.setMessage(sa.hasParam("AnyNumber") ? "Discard up to %d card(s)" : "Discard %d card(s)"); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); return inp.getSelected(); } @@ -617,7 +617,7 @@ public class PlayerControllerHuman extends PlayerController { } }; target.setMessage("Select %d card(s) to discard, unless you discard a " + uType + "."); - Singletons.getControl().getInputQueue().setInputAndWait(target); + target.showAndWait(); return target.getSelected(); } @@ -655,7 +655,7 @@ public class PlayerControllerHuman extends PlayerController { @Override public List getCardsToMulligan(boolean isCommander, Player firstPlayer) { final InputConfirmMulligan inp = new InputConfirmMulligan(player, firstPlayer, isCommander); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); return inp.isKeepHand() ? null : isCommander ? inp.getSelectedCards() : player.getCardsIn(ZoneType.Hand); } @@ -663,14 +663,14 @@ public class PlayerControllerHuman extends PlayerController { public void declareAttackers(Player attacker, Combat combat) { // This input should not modify combat object itself, but should return user choice InputAttack inpAttack = new InputAttack(attacker, player, combat); - Singletons.getControl().getInputQueue().setInputAndWait(inpAttack); + inpAttack.showAndWait(); } @Override public void declareBlockers(Player defender, Combat combat) { // This input should not modify combat object itself, but should return user choice InputBlock inpBlock = new InputBlock(player, defender, combat); - Singletons.getControl().getInputQueue().setInputAndWait(inpBlock); + inpBlock.showAndWait(); } @Override @@ -691,7 +691,7 @@ public class PlayerControllerHuman extends PlayerController { if (game.isGameOver()) { return; } //don't wait to pass priority if player conceded while in middle of playing a spell/ability } InputPassPriority defaultInput = new InputPassPriority(player); - Singletons.getControl().getInputQueue().setInputAndWait(defaultInput); + defaultInput.showAndWait(); chosenSa = defaultInput.getChosenSa(); } while (chosenSa != null); } @@ -706,7 +706,7 @@ public class PlayerControllerHuman extends PlayerController { String message = String.format(msgFmt, max, n, nDiscard); inp.setMessage(message); inp.setCancelAllowed(false); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); return inp.getSelected(); } @@ -719,7 +719,7 @@ public class PlayerControllerHuman extends PlayerController { min = Math.min(min, max); InputSelectCardsFromList inp = new InputSelectCardsFromList(min, max, valid); inp.setMessage("Choose Which Cards to Reveal"); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); return inp.getSelected(); } diff --git a/forge-gui/src/main/java/forge/game/spellability/TargetSelection.java b/forge-gui/src/main/java/forge/game/spellability/TargetSelection.java index bb25e34c688..56cf60066d0 100644 --- a/forge-gui/src/main/java/forge/game/spellability/TargetSelection.java +++ b/forge-gui/src/main/java/forge/game/spellability/TargetSelection.java @@ -23,7 +23,6 @@ import java.util.List; import com.google.common.base.Predicate; import com.google.common.collect.Lists; -import forge.Singletons; import forge.game.Game; import forge.game.GameObject; import forge.game.card.Card; @@ -108,7 +107,7 @@ public class TargetSelection { List validTargets = this.getValidCardsToTarget(); if (zone.size() == 1 && (zone.get(0) == ZoneType.Battlefield || zone.get(0) == ZoneType.Hand)) { InputSelectTargets inp = new InputSelectTargets(validTargets, ability, mandatory); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); choiceResult = !inp.hasCancelled(); bTargetingDone = inp.hasPressedOk(); } else { diff --git a/forge-gui/src/main/java/forge/game/zone/MagicStack.java b/forge-gui/src/main/java/forge/game/zone/MagicStack.java index 9ba9a01721b..1b483f6f425 100644 --- a/forge-gui/src/main/java/forge/game/zone/MagicStack.java +++ b/forge-gui/src/main/java/forge/game/zone/MagicStack.java @@ -31,7 +31,6 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.FThreads; -import forge.Singletons; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.card.mana.ManaCost; @@ -633,7 +632,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable @@ -41,7 +41,7 @@ public class InputYesOrNo extends InputSyncronizedBase { } public static boolean ask(String message0, String yesButtonText0, String noButtonText0, boolean defaultYes0) { InputYesOrNo inp = new InputYesOrNo(message0, yesButtonText0, noButtonText0, defaultYes0); - Singletons.getControl().getInputQueue().setInputAndWait(inp); + inp.showAndWait(); return inp.getResult(); }